// var ajaxUrl = 'http://bingge.59156.cn';
// var ajaxUrl = 'http://www.urbubble.com';
var ajaxUrl = 'http://app.unicia.com.cn/';

var token = '';
var vsersion_code = 60;
var ios_code = 11;
var commonNote = 'Hello,UNICIA.';

//设置底部导航链接
var frames = [
    {
        name: 'index',
        url: '../../html/index/index.html',
        bounces: false
    }, {
        name: 'circle',
        url: '../../html/circle/circle.html',
        bounces: false
    }, {
        name: 'school_index',
        url: '../../html/school/school_index.html',
        bounces: false
    }, {
        name: 'match_index',
        url: '../../html/match/match_index.html',
        bounces: false
    }, {
        name: 'member',
        url: '../../html/member/member.html',
        bounces: false
    }
];


function getMember(fn) {
    var param = {
        token: $api.getStorage('token')
    }
    getAjax(Interface.memberIndex, param, function (res) {
        var data = res.data;
        fn(res)
        $api.setStorage('userInfo',data);
        // if(isDefine(data.attestation_status)){
        //     rzStatus = data.attestation_status;
        // }
    }, function (error) {

    })
}


// 底部导航栏切换 打开方式自定义
function randomSwitchBtn(tag) {
    var _index = $(tag).index();
    if (tag == $api.dom('#footer li.active')){
        if(_index == 0||_index == 1)
        api.sendEvent({
            name: 'refresh',
            extra: {}
        });
        $('.mescroll').animate({scrollTop:0},500);//回到顶端
        return;
    }
    var status = $api.getStorage('schoolPath_status');
    if (_index == 2) {
        var rzStatus = '';
        getMember(function (res) {
            rzStatus = res.data.attestation_status;
            if(rzStatus != 2){
                $("body").append(rzHtml);
                return;
            }
            api.openWin({
                name: frames[_index].name,
                url: frames[_index].url,
                // reload: true,
                slidBackEnabled: false,
                allowEdit: true,
                animation:{
                    type:'none'
                },
                pageParam: {

                }
            });
            var arr = [frames[_index].name];
            $api.setStorage('beforePath',arr);
            console.log(jsonChange($api.getStorage('beforePath')))
        })

    } else if(_index == 1){
        var newslogin = $api.getStorage('newLogin');
        if(newslogin == 1){
            api.openWin({
                name: frames[_index].name,
                url: frames[_index].url,
                reload: true,
                slidBackEnabled: false,
                allowEdit: true,
                animation:{
                    type:'none'
                },
                pageParam: {

                }
            });
            $api.setStorage('newLogin',2);
            var arr = [frames[_index].name];
            $api.setStorage('beforePath',arr);
            console.log(jsonChange($api.getStorage('beforePath')))

        }else {
            api.openWin({
                name: frames[_index].name,
                url: frames[_index].url,
                // reload: true,
                slidBackEnabled: false,
                allowEdit: true,
                animation:{
                    type:'none'
                },
                pageParam: {

                }
            });
            var arr = [frames[_index].name];
            $api.setStorage('beforePath',arr);
            console.log(jsonChange($api.getStorage('beforePath')))
        }
    }else {
        api.openWin({
            name: frames[_index].name,
            url: frames[_index].url,
            // reload: true,
            slidBackEnabled: false,
            allowEdit: true,
            animation:{
                type:'none'
            },
            pageParam: {

            }
        });
        var arr = [frames[_index].name];
        $api.setStorage('beforePath',arr);
        console.log(jsonChange($api.getStorage('beforePath')))
    }

    if(_index == 4){
        $api.fixStatusBar($api.dom('#header'));
        api.setStatusBarStyle({
            style: 'light', //设置APP状态栏字体色
            color: 'rgba(255,255,255,0)', //设置APP状态栏背景色
        });
    }else {
        setFixStatusBar(); //设置状态栏
    }
    /*window.location.href = frames[_index].url;*/

}

//设置导航栏颜色
function setFixStatusBar() {
    $api.fixStatusBar($api.dom('#header'));
    api.setStatusBarStyle({
        style: 'dark',
        color: '#fff'
    });
}

//是否为iosX
function isIosX() {
    var deviceModel = api.deviceModel;  // 比如iPhone X的型号： iPhone10,3
    // if(deviceModel == 'iPhone10,3'){
    //     $('#footer').addClass('iosX')
    // }
}


function doZyMediaJs(flag) {
    if(flag){
        zymedia('#video',{
            autoplay: false,
            alwaysShowControls: true,
            preload: 'auto',
        })
    }else {
        zymedia('#video',{
            mediaTitle: title,
            autoplay: false,
            alwaysShowControls: true,
            preload: 'auto',
        })
    }

}
function doZyMediaJsVideo(flag) {
    if(flag){
        zymedia('.video-js',{
            autoplay: false,
            alwaysShowControls: true,
            preload: 'auto',
        })
    }else {
        zymedia('.video-js',{
            // mediaTitle: title,
            autoplay: false,
            alwaysShowControls: true,
            preload: 'auto',
        })
    }

}

/* video.js */

function getVideoJs() {
    var videos = $('video');
    for (var i = videos.length - 1; i >= 0; i--) {
        videojs(videos[i], {
            muted: false,
            controls: true,
            loop: false,
            preload: false,
            // 更多配置.....
        });
        //匿名函数 监听播放
        (function(){
            var p = i;
            videos[p].addEventListener('play',function(){
                pauseAll(p);
            })
            videos[p].addEventListener('pause',function(){
                $(videos[p]).siblings(".vjs-big-play-button").css("display", "block");
            })
        })()
    }
    function pauseAll(index){
        console.log(index)
        for (var j = videos.length - 1; j >= 0; j--) {
            if (j!=index) videos[j].pause();
            $(videos[j]).siblings(".vjs-big-play-button").css("display", "block");
            $(videos[index]).siblings(".vjs-big-play-button").css("display", "none");
        }
    }
}


/* video.js end */


//ios 审核使用
function SystemCheckVersion(status){
    getversion(function(res){
        var sysType = api.systemType;
        if(sysType == 'ios'){
            if (isDefine(res.data.ios_number)){

                if(ios_code > res.data.ios_number){

                    $('.jubao').show()
                    $(".share-view").hide();
                    $(".threeShare").hide();
                    if(status == 1){
                        $(".shareTitle").html('分享')
                    }else {
                        $(".shareTitle").html('举报')
                    }
                    $(".shield").addClass('on');
                    $(".threeLogin").hide();
                    $("#idea").show();

                    // switchController()

                }else {
                    $('.jubao').hide()
                    // $(".action-btn").show();
                    // $(".action-btn-white").show();

                    $(".share-view").show();
                    $(".threeShare").show();
                    $(".shareTitle").html('分享');
                    $(".threeLogin").show();
                    $(".shield").removeClass('on');


                    $("#idea").hide()
                    $("#encourage").show()
                }
            }
        }else if(sysType == 'android'){
            $('.jubao').hide();

            $(".share-view").show();
            $(".threeShare").show();
            $(".shareTitle").html('分享');
            $(".threeLogin").show();

            // $(".shareTitle").html('举报');

            $("#idea").hide()
            /*if(data == 1){
                $("#encourage").hide()
            }else {
                $("#encourage").show()
            }*/
            $("#encourage").show()
        }
    })
}



//开关接口
function switchController(status,fn) {
    getAjax(Interface.get_on_off,'',function (res) {
        var data = res.data;
        console.log('开关状态:'+jsonChange(res))
        if(isDefine(fn)){
          fn(res);
        }
        if (api.systemType == 'ios'){
            if(data == 1){
                $('.jubao').show()

                // $(".action-btn").hide();
                // $(".action-btn-white").hide();
                $(".share-view").hide();
                $(".threeShare").hide();
                if(status == 1){
                    $(".shareTitle").html('分享')
                }else {
                    $(".shareTitle").html('举报')
                }
                $(".shield").addClass('on');
                $(".threeLogin").hide();

                $("#idea").show()

            }else {
                $('.jubao').hide()

                // $(".action-btn").show();
                // $(".action-btn-white").show();


                $(".share-view").show();
                $(".threeShare").show();
                $(".shareTitle").html('分享');
                $(".threeLogin").show();
                $(".shield").removeClass('on');


                $("#idea").hide()
            }
            $("#encourage").show()

        } else {
            $('.jubao').hide()

            $(".share-view").show();
            $(".threeShare").show();
            $(".shareTitle").html('分享');
            $(".threeLogin").show();

            // $(".shareTitle").html('举报');

            $("#idea").hide()
            /*if(data == 1){
                $("#encourage").hide()
            }else {
                $("#encourage").show()
            }*/
            $("#encourage").show()
        }

    },function (error) {

    })
}

function switchController2(fn) {
    getAjax(Interface.get_on_off2,'',function (res) {
        var data = res.data;
        fn(res);

    },function (error) {

    })
}

//跳转徽章
function toBadgePage(event) {
    event.stopPropagation();
    commonUrl('../member/huizhang')
}


//接口列表
var Interface = {
    get_on_off: '/api/index/get_on_off',//ios 审核开关
    get_on_off2: '/api/index/get_on_off2',//华为 注销功能审核开关
    get_guide: '/api/index/get_guide',//获取引导页
    memberIndex: '/api/member/member_index',//会员中心首页
    set_sms: '/api/login/set_sms',//短信接口
    login: '/api/login/login',//登录
    get_information: '/api/index/get_information',//获取完善信息参数,类型：1查询在读阶段 2查询城市 3查询学科 4查询学校，查询学校必须要城市id 5查询入学年份
    get_city: '/api/index/get_city',//查询城市
    set_member: '/api/login/set_member',//完善个人信息/学生认证
    upload_img: '/api/uploads/upload',//图片上传
    editor_upload: '/api/uploads/editor_upload',//图片上传2 发帖使用
    upload_file: '/api/uploads/upload_file',//上传视频
    set_open: '/api/member/set_open',//开启旅程
    get_circle: '/api/member/get_login_circle',//获取推荐圈子
    edit_password: '/api/member/edit_password',//修改、设置密码
    get_nav: '/api/index/get_nav',//修改、设置密码
    index: '/api/news/index',//首页接口
    get_badge: '/api/member/get_badge',//获取徽章列表（或者自己的）
    edit_member: '/api/member/edit_member',//编辑资料
    edit_name: '/api/member/edit_name',//编辑昵称
    bind_tel: '/api/login/bind_tel',//第三方登录绑定手机号、绑定手机号
    edit_tel: '/api/member/edit_tel',//修改绑定手机号
    discuss_vote: '/api/discuss/discuss_vote',//话题投票 类型：1支持 0反对
    discuss_home: '/api/discuss/discuss_home',//话题详情
    discuss_indx: '/api/discuss/index',//话题列表
    discuss_updown: '/api/discuss/discuss_updown',//话题发言点赞、点踩, type类型：1赞 2踩
    news_details: '/api/news/news_details',//新闻详情
    news_lists: '/api/news/lists',//相关新闻列表
    set_activity: '/api/invitation/set_activity',//发布活动贴
    activity_details: '/api/invitation/activity_details',//活动贴详情(有评论的)
    activity_one: '/api/invitation/activity_one',//活动贴详情
    get_activity_information: '/api/invitation/get_activity_information',//查询活动报名需要填写信息（报名）
    get_act_info: '/api/invitation/get_information',//查询活动贴分类和选填信息

    activity_up: '/api/invitation/activity_up',//活动报名 - 报名信息，用逗号分隔，顺序不能乱
    activity_cancel: '/api/member/activity_cancel',//会员取消活动
    activity_out: '/api/member/activity_out',//退出活动报名
    get_activity_list: '/api/invitation/get_activity',//退出活动报名
    comment_add: '/api/comment/comment_add',//添加评论 type类型：1新闻 2帖子 3活动 0回复
    news_fabulous: '/api/news/news_fabulous',//点赞喜欢/取消点赞 stype类型：1点赞 2取消点赞； type类型：1新闻 2帖子 3活动 4评论
    set_follow: '/api/school/set_follow',//选择关注学校圈子
    get_school_city: '/api/index/get_school_city',//选择学校城市

    member_home: '/api/member/member_home',//获取他人会员主页

    circle_index: '/api/invitation/index',//圈子首页
    find_circle: '/api/circle/get_circle',//获取圈子一级分类、二级分类，圈子
    circle_follows: '/api/circle/circle_follows',//获取会员更多关注、推荐圈子
    search_circle: '/api/circle/search_circle',//搜索圈子列表

    about: '/api/member/about',//关于我们页面
    get_activity: '/api/member/get_activity',//会员中心获取活动
    activity_pone: '/api/invitation/activity_pone',//活动评星页面，查看评星页面
    activity_evaluate: '/api/invitation/activity_evaluate',//活动评星

    set_invitation: '/api/invitation/set_invitation',//会员发布帖子
    invitation_details: '/api/invitation/invitation_details',//帖子详情
    follow: '/api/member/set_follow',//关注/取消关注（会员/圈子）

    search_history: '/api/search/index',//搜索关键词记录展示，热门搜索
    del_search: '/api/search/del_search',//会员删除历史记录
    search: '/api/search/search',//搜索结果

    get_comment: '/api/comment/get_comment',//评论详情，所有下级评论
    collection: '/api/member/collection',//会员添加收藏
    collection_cancel: '/api/member/collection_cancel',//会员添加收藏

    /* 高校 */
    school_list: '/api/school/school_list',//获取校徽首页学校圈子横条
    school_index: '/api/school/index',//获取校徽主要数据 type 类型：1动态 2圈子 3简介 4排名
    school_follow: '/api/school/school_follow',//我关注的学校
    school_address: '/api/school/school_address',//我关注的学校
    set_match_school: '/api/match/set_match_school',//会员关注校园开启赛事提醒

    /* 圈子详情 */
    circle_home: '/api/circle/circle_home',//圈子详情
    get_square: '/api/circle/get_square',//圈子广场详情
    get_circle_content: '/api/circle/get_circle_content',//如何成为圈主
    set_circle_member: '/api/circle/set_circle_member',//申请成为圈主
    circle_hotmember: '/api/circle/circle_hotmember',//圈子热度榜
    get_circle_notice: '/api/circle/get_circle_notice',//圈子置顶消息详情

    //会员中心
    other_login: '/api/login/other_login',//第三方快捷登录
    get_invitation: '/api/member/get_invitation',//查询我发表的帖子
    get_follow: '/api/member/get_follow',//获取关注
    get_collection: '/api/member/get_collection',//我的收藏
    set_contribute: '/api/member/set_contribute',//投稿
    get_contribute_type: '/api/member/get_contribute_type',//获取投稿类型
    set_report: '/api/member/set_report',//获取投稿类型
    get_browse: '/api/member/get_browse',//查询会员浏览记录
    get_fabulous_list: '/api/member/get_fabulous_list',//获取会员点赞列表
    get_contribute: '/api/member/get_contribute',//反馈记录
    browse_del: '/api/member/browse_del',//清空浏览记录
    get_fans: '/api/member/get_fans',//获取粉丝
    get_fabulous: '/api/member/get_fabulous',//我的获赞
    forget_password: '/api/login/forget_password',//忘记密码
    bind_auth: '/api/member/bind_auth',//绑定第三方
    get_notice: '/api/member/get_notice',//我的消息
    get_standard: '/api/member/get_standard',//档案库
    apply_badge: '/api/member/apply_badge',//申请徽章
    get_notice_details: '/api/member/get_notice_details',//获取消息列表
    notice_del: '/api/member/notice_del',

    //赛事中心
    team_details: '/api/team/team_details',//球队主页
    get_player: '/api/team/get_player',//队员信息
    get_career: '/api/team/get_career',//队员生涯信息
    get_nave: '/api/team/get_nave',//获取赛事导航 类型type：1比赛 2数据
    match_index: '/api/match/match_index',//获取赛事比赛的首页数据   类型type：1今天 2今天以前 3今天以后
    match_index2: '/api/match/match_index2',//获取赛事比赛的首页数据   类型type：1今天 2今天以前 3今天以后(新赛事接口)
    match_details: '/api/match/match_details',//获取赛事主页上半部分，返回的信息有是否是团队赛
    match_xia: '/api/match/match_xia',//获取对抗赛，下半部分 类型type：1 评论 2赛况 3阵容
    get_match_war: '/api/match/get_match_war',//获取对抗赛，下半部分 类型type：1 评论 2赛况 3阵容
    get_prize_lower: '/api/match/get_prize_lower',//获取团队赛主页下半部分 类型type：1简介 2获取队伍 3赛后战报
    get_season: '/api/match/get_season',//获取赛事赛季，赛程导航  类型type：1：获取赛季 2：获取赛程
    get_player_list: '/api/match/get_player_list',//获取赛事球员榜左侧导航
    get_rank: '/api/match/get_rank',//获取赛季排位数据
    get_small_group: '/api/match/get_small_group',//获取赛事数据，小组数据
    set_team_follow: '/api/team/set_team_follow',//会员关注球队
    set_remind: '/api/team/set_remind',//会员开启，关注赛事提醒
    get_match_details: '/api/match/get_match_details',//会员开启，关注赛事提醒

    //积分
    get_integral: '/api/member/get_integral',//积分主页
    integral_details: '/api/member/integral_details',//积分详情
    add_screen: '/api/news/add_screen',//积分详情

    check_version: '/api/index/get_edition',//版本更新
    get_shield: '/api/member/get_shield',//获取屏蔽列表
    del_shield: '/api/member/del_shield',//移出屏蔽

    share_app: '/api/member/share_app',//分享app
    share_login: '/api/member/share_login',//邀请新用户

    //注销账号
    member_del: '/api/member/member_del',//注销账号
    encourage: '/api/index/encourage',//鼓励一下

    look_match: '/api/match/look_match',//监听观看赛事视频


    //一级优化接口
    release_vote: '/api/svote/release_vote',//会员发布投票
    circle_list: '/api/circle/circle_list',//获取圈子页面的头部圈子
    circle_dynamic: '/api/circle/index',//获取圈子页面的下半部分
    set_vote: '/api/svote/set_vote',//会员投票
    circle_gc: '/api/circle/circle_gc',//获取圈子广场

    set_circle_px: '/api/circle/set_circle_px',//圈子广场添加评星
    gc_details_top: '/api/circle/gc_details_top',//获取广场详情上半部
    gc_details_lower: '/api/circle/gc_details_lower',//获取广场详情下半部分

    vote_details: '/api/svote/vote_details',//获取会员发布投票详情
    get_vote_footer: '/api/svote/get_vote_footer',//获取会员发布投票下半部分
    vote_result: '/api/svote/vote_result',//获取投票结果 type 为1表示新闻投票 2会员发布投票

    news_vote: '/api/svote/news_vote',//获取新闻赛况投票数据,类型：1新闻 2赛况

    getAllList: '/api/comment/get_comment_list',//获取所有评论列表 type: 1新闻，2帖子，3活动贴，4赛事，5战况，6投票，7广场评星

    userText: '/api/login/xieyi',//参数：type   1:隐私政策。 2，用户协议

    get_lng_lat:'/api/login/get_lng_lat', //参数 start_addr    //新增获取经纬度接口


    new_share:'/api/member/new_share', //分享成功回执


};

//调用接口
function getAjax(url, jsonData, fn, fnError) {
    console.log(url);
    console.log(JSON.stringify(jsonData));
    api.ajax({
        url: ajaxUrl + url,
        method: 'post',
        data: {body: jsonData},
        headers: {
            "Content-Type": "application/json; charset=utf-8"
        },
        async:false,
    }, function (ret, err) {
        // console.log(JSON.stringify(ret));
        if (ret) {
            if (ret.status == 200) {
                fn(ret);
            } else {
                pop.close();
                // console.log(JSON.stringify(jsonData));
                console.log(JSON.stringify(ret));
                if(ret.status == 202){
                    pop.notice('账号登录异常，请重新登录',2,function () {
                        individualUrl('../login/login_pwd')
                    })
                } else if (ret.status == 403) {
                    $api.setStorage('token', null);
                    token = null;
                    pop.notice(ret.msg, 1.5, function () {
                        comeBack();
                    });
                } else {
                    if (url == Interface.login) {//收藏

                    } else {
                        // pop.notice(ret.msg);
                    }
                    fnError(ret, err);
                }
            }
        } else {
            pop.close();
            console.log(JSON.stringify(err));
            // console.log(JSON.stringify(jsonData));
            //（err.code0：连接错误、1：超时、2：授权错误、3：数据类型错误、4：不安全的数据）
            var isnull = false;
            var layers = "";
            switch (err.statusCode) {
                case 0:
                    layers = "网络不给力哦！请稍后重试";
                    isnull = true;
                    break;
                case 1:
                    layers = "连接超时，请稍后重试";
                    isnull = true;
                    break;
                case 2:
                    layers = "授权错误";
                    isnull = true;
                    break;
                case 4:
                    layers = "不安全的数据";
                    isnull = true;
                    break;
            }
            if (isnull) {
                pop.notice(layers);
            } else {

            }
        }
    });
}


//极光推送
function ajpush(){
    var did = api.deviceId;
    console.log(did);
    did = did.replace(/-/g,'');
    var ajpush = api.require('ajpush');
    if(api.systemType == "android"){
        ajpush.init(function(ret) {
            var param = {alias:did,tags:did};

            console.log(JSON.stringify(param));
            ajpush.bindAliasAndTags(param,function(rete) {
                //alert(rete.statusCode);
            });
            ajpush.setListener(function (ret){
                setTimeout(function () {
                    ajpushLink(ret.extra,function (result) {
                        commonUrl(result.url,jsonChange(result.urlParam))
                    });
                },500);
            });

        });
    }else if(api.systemType == "ios"){
        ajpush.setListener(function (ret){
            setTimeout(function () {
                ajpushLink(ret.extra,function (result) {
                    commonUrl(result.url,jsonChange(result.urlParam))

                });
            },500);
        });
        var param = {alias:did,tags:did};
        console.log(JSON.stringify(param));
        ajpush.bindAliasAndTags(param,function(ret) {

        });

    }

}


//极光推送 - 跳转页面判断
function ajpushLink(item,fn) {
    var url = '',urlParam = '';
    // var item = {resour_type: 1,resour_id: 406}
    switch (item.resour_type) {
        case 0:
            if(item.leixing == 4){
                url = '../member/myFans';
                urlParam = {};
            }
            break;
        case 1:
            // result = '新闻';
            url = '../index/news_detail';
            urlParam = {'news_id': item.resour_id};
            break;
        case 2:
            //result = '帖子';
            url = '../circle/invite_detail';
            urlParam = {'invitation_id': item.resour_id};
            if (item.leixing == 2) {
                if(item.comment_id != 0){
                    url = '../activity/comment_detail';
                    urlParam = {"id": item.comment_id, detail_id: item.resour_id};
                }else {
                    url = '../circle/invite_detail';
                    urlParam = {'invitation_id': item.resour_id};
                }
            }
            break;
        case 3:
            //result = '活动';
            url = '../activity/activity_index';
            urlParam = {"activity_id": item.resour_id};
            break;
        case 4:
            //result = '评论';
            url = '../activity/comment_detail';
            urlParam = {"id": item.comment_id, detail_id: item.resour_id};
            break;
        case 5:
            //result = '话题';
            url = '../index/topic_detail';
            urlParam = {"discuss_id": item.resour_id, "today": 2};
            break;
    }
    var str = {
        url: url,
        urlParam: urlParam
    };
    fn(str)
}

//检测设备操作系统
function checkSystemType(fn1,fn2) {

    var systemType = api.systemType;
    if(systemType == 'ios'){
        fn1();
    }else if(systemType == 'android'){
        fn2();
    }

}



//上拉加载
function pullUpLoading(loading) {

    api.addEventListener({
        name: 'scrolltobottom',
        extra: {
            threshold: 100,
        }
    }, function(ret, err) {
        loading(ret, err);
    });
}

//下拉刷新
function dropDownRefresh(refresh) {
    /** 下拉刷新 */
    api.setRefreshHeaderInfo({
        bgColor: '#ccc',
        textColor: '#fff',
        textDown: '下拉刷新...',
        textUp: '松开刷新...'
    }, function (ret, err) {

        refresh(ret, err)
        // 取消下拉刷新效果
        api.refreshHeaderLoadDone();


    });
}

function copy(text) {
    //text为需要复制的文本
    var clipBoard = api.require('clipBoard');
    clipBoard.set({
        value: text
    }, function(ret, err) {
        if (ret) {
            pop.notice('复制成功')

            closeModel(event)

        } else {
            pop.notice('复制失败')
        }
    });
}




//缓存用户信息
if ($api.getStorage('user') != null && $api.getStorage('user') != "undefined") {
    var user = $api.getStorage('user');
    var islogin = 1;
} else {
    var islogin = 0;
}

//验证判断 - 邮箱
function reEmail(val) {
    var reEmail = /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/;
    return reEmail.test(val);
}

//验证判断 - 电话
function regTel(val) {
    var regTel = /^[1][3-9][0-9]{9}$/;
    return regTel.test(val);
}

//对手机号中间四位进行加密
function hideTel(text) {
    var text = text;
    var reg = /^(\d{3})\d{4}(\d{4})$/;
    text = text.replace(reg, "$1****$2");
    return text;
}

//验证判断 - 身份证
function isIdCard(val) {
    var regIdCard = /^(^d{15}$)|(^d{17}([0-9]|X)$)$/;
    return regIdCard.test(val);
}

//转换JSON
function jsonChange(val) {
    var jsonVal = JSON.stringify(val);
    return jsonVal;
}


//弹出框统一封装
var pop = {
    notice: function (content, time, fn) {//content 内容 time 时间 单位秒 fn 消息弹出后执行的方法
        //uexWindow.toast('0', '5', content, time*1000);
        var timeVal = 2000;
        if (isDefine(time)) {
            timeVal = time * 1000;
        }
        //提示
        api.toast({
            msg: content,
            duration: timeVal
        });
        if (fn) {
            setTimeout(function () {
                fn();
            }, timeVal);
        }
    },
    loading: function (text) {
        var title = "加载中...";
        var txt = "请稍候...";
        if (isDefine(text)) {
            title = text;
        }

        var html = '<div class="LoadingGif">' +
            '           <div class="gif"></div>' +
            '       </div>';
        /*api.showProgress({
            style: 'default',
            animationType: 'fade',
            title: title,
            text: txt,
            modal: true
        });*/
        // $('body').append(html)
    },
    close: function () {
        // $(".LoadingGif").remove();
        api.hideProgress();
    }
}


//支付宝支付
function alipay(orderno, gopays) {
    var aliPayPlus = api.require('aliPayPlus');
    console.log(orderno);
    aliPayPlus.payOrder({
        orderInfo: orderno
    }, function (ret, err) {
        console.log(jsonp(err));
        console.log(jsonp(ret));
        if (ret.code == 9000) {
            pop.notice('支付成功');
            gopays(ret);
        } else {
            if (ret.code == 6001) {
                pop.notice('支付已取消');
            } else {
                pop.notice('支付失败');
                console.log('支付失败 code:' + err.code + err.msg);
            }
        }
    });
}

//微信支付
function wxpay(apiKey, prepay_id, mchId, nonceStr, timeStamp, sign, gopays) {
    console.log('调用微信支付');
    var wxPay = api.require('wxPay');
    var payParam = {
        apiKey: apiKey,
        orderId: prepay_id,
        mchId: mchId,
        nonceStr: nonceStr,
        timeStamp: timeStamp,
        //package: 'Sign=WXPay',
        sign: sign
    };
    console.log(jsonp(payParam));
    wxPay.payOrder(payParam, function (ret, err) {
        //alert(JSON.stringify(ret));
        //alert(JSON.stringify(err));
        if (ret.status) {
            pop.notice('支付成功');
            gopays(ret);
        } else {
            if (err.code == '-2') {
                pop.notice('取消支付');
            } else {
                pop.notice('支付失败');
            }
        }
    });
}


//判断非空值
function isDefine(para) {
    if (typeof para == "undefined" || para == "" || para == "[]" || para == null || para == undefined) {
        return false;
    } else if (typeof para == "number" || para == "number" || para == "null") {
        return true;
    } else if (para == null || para == undefined) {
        return true;
    } else {
        for (var o in para) {
            return true;
        }
        return false;
    }
}

//转换时间戳
function timestampToTime(timestamp, type) {
    //时间戳为10位需*1000，时间戳为13位的话不需乘1000
    //console.log((""+timestamp).length);
    if (("" + timestamp).length == 10) {
        timestamp *= 1000;
    }
    var date = new Date(timestamp);
    Y = date.getFullYear() + '-';
    M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
    h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
    m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
    s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
    if (type == 'yyyy-MM-dd hh:mm:ss') {
        return Y + M + D + h + m + s;
    } else if (type == 'yyyy-MM-dd') {
        return Y + M + D;
    } else if (type == 'hh:mm:ss') {
        return h + m + s;
    } else if (type == 'yyyy-MM-dd hh:mm') {
        m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
        return Y + M + D + h + m;
    }
    return Y + M + D + h + m + s;
}

//拨打电话
function call(tel) {
    console.log(tel);
    api.call({type: 'tel_prompt', number: tel});
}


//打开网页
function openLink(type, url) {
    if (type == 1) {
        api.openApp({
            androidPkg: 'android.intent.action.VIEW',
            mimeType: 'text/html',
            uri: url,
            iosUrl: url,
        }, function (ret, err) {

        });
    } else {
        goWare(url);
    }
}


//banner链接跳转
function toUrl(url, id) {
    console.log(url)
    if (isDefine(url)) {
        var param = '';
        if(isDefine(id)){
            param = {"url": url,"news_id": id}
        } else {
            param = {"url": url}
        }
        var path = '../index/banner_detail';
        var pathArr = path.split('/');
        var pathName = pathArr[pathArr.length - 1];
        console.log('当前链接路径：' + jsonChange(path) + '，跳转传参：' + JSON.stringify(param));
        api.openWin({
            name: pathName,
            url: path + '.html',
            reload: true,
            slidBackEnabled: true,
            allowEdit: true,
            pageParam: param
        });
    } else {
        var urlParam = {"news_id": id}
        commonUrl('../index/news_detail', urlParam);
    }

}

//在浏览器中打开
function openURLInApp(url) {
    //判断操作系统
    if (api.systemType == 'android') {
        // console.log(url)
        //Android中的使用方法如下：
        api.openApp({
            // androidPkg: 'android.intent.action.VIEW',
            // mimeType: 'text/html',
            uri: url
        }, function (ret, err) {

        });
    } else {
        //iOS中的使用方法如下：
        api.openApp({
            iosUrl: url
        });
    }
}


//检测url 是否包含http
function checkUrl(str) {
    if (str.indexOf('http') == 0) {
        return true;
    } else {
        return false;
    }
}

//下拉刷新
function toDoRefresh() {
    setTimeout(function () {
        location.reload();
        api.refreshHeaderLoadDone(); //复位下拉刷新
        api.toast({
            msg: '刷新成功',
            duration: '1000',
            localtion: 'middle'
        });
    }, 2000)
}

//三方检测
function checked_three() {
    check_wb();
    check_qq();
    check_wx()
}

//三方检测 -- 检测微博
function check_wb() {
    var weibo = api.require('weiboPlus');
    weibo.isInstalled(function (ret) {
        if (!ret.status) {
            $(".wb").hide();
        } else {

        }
    });
}

//三方检测 -- 检测qq
function check_qq() {
    var qq = api.require('QQPlus');
    var openId = '';
    qq.installed(function (ret, err) {
        if (!ret.status) {
            $(".qq").hide();
        } else {

        }
    });
}

//三方检测 -- 检测微信
function check_wx() {
    var wx = api.require('wxPlus');
    var code = '';
    wx.isInstalled(function (ret, err) {
        if (!ret.installed) {
            $(".wx").hide();
        } else {

        }
    });
}


//检测是否登录
function loginCheck() {
    if (token == '' || token == null || token == undefined) {
        alert('您尚未登录,请登录')
        aaplay('login_account');
        return false;
    } else {
        // var p ={token:token}
        // console.log(JSON.stringify(token))
        // api.ajax({
        //     url: webSiteUrl + '/App/home/checkIndividual',
        //     method: 'post',
        //     data: {
        //         values: p
        //     }
        // }, function(ret, err) {
        //   console.log(JSON.stringify(ret));
        //   if(ret.status==false){
        //     alert('您尚未登录,请登录')
        //     api.openWin({
        //         name: 'login_account',
        //         url: 'login_account.html',
        //         reload:true,
        //         pageParam: {
        //
        //         }
        //     });
        //   }
        // })
        return true;
    }
}

//判断是否有权限
function hasPermissions(type) {
    var resultList = api.hasPermission({
        list: [type]
    });
    console.log(JSON.stringify(resultList));
    return resultList[0].granted;
}


function isGetPermissions() {
    //获取存储权限
    var resultList3 = api.hasPermission({
        // list: ['storage'],
        list: ['storage','camera','location','notification']
    });

    if (resultList3[0].granted) {
    } else {
        api.requestPermission({
            list: ['storage'],
            code: 3
        }, function(ret, err) {

            if (resultList3[1].granted) {
            } else {
                api.requestPermission({
                    list: ['camera'],
                    code: 3
                }, function(ret, err) {

                    if (resultList3[2].granted) {
                    } else {
                        api.requestPermission({
                            list: ['location'],
                            code: 3
                        }, function(ret, err) {

                            if(api.systemType == 'ios'){
                                if (resultList3[3].granted) {
                                } else {
                                    api.requestPermission({
                                        list: ['notification'],
                                        code: 3
                                    }, function(ret, err) {

                                    });
                                }
                            }else {
                                openApp()
                            }
                        })
                    }


                });
            }

        });
    }
}


//相机 -- 设置中打开相机的使用权限
function hasPermissions_camas() {
    var has = hasPermissions('camera');
    var has2 = hasPermissions('storage');
    if (has == false) {
        api.requestPermission({
            list: ['camera'],
            code: 100001
        }, function (ret, err) {
            console.log(JSON.stringify(ret));
            var result = ret.list[0].granted;
            var never = ret.never;
            if (never == true && result == false) {
                api.toast({
                    msg: '请在设置中打开相机的使用权限',
                });
                return false;
            }
            if (result == false) {
                return false;
            }
            if (has2 == false) {
                api.requestPermission({
                    list: ['storage'],
                    code: 100001
                }, function (ret, err) {
                    console.log(JSON.stringify(ret));
                    var result = ret.list[0].granted;
                    var never = ret.never;
                    if (never == true && result == false) {
                        api.toast({
                            msg: '请在设置中打开读取存储空间的权限',
                        });
                        return false;
                    }
                    if (result == false) {
                        return false;
                    }
                    return true;
                });
            }
        });
    } else {
        if (has2 == false) {
            api.requestPermission({
                list: ['storage'],
                code: 100001
            }, function (ret, err) {
                console.log(JSON.stringify(ret));
                var result = ret.list[0].granted;
                var never = ret.never;
                if (never == true && result == false) {
                    api.toast({
                        msg: '请在设置中打开读取存储空间的权限',
                    });
                    return false;
                }
                if (result == false) {
                    return false;
                }
                return true;
            });
        }
    }
    if (has && has2) {
        return true;
    }
}

//相机 -- 打开读取存储空间的权限
function hasPermissions_hasPermissions() {
    var has2 = hasPermissions('storage');
    if (has2 == false) {
        api.requestPermission({
            list: ['storage'],
            code: 100001
        }, function (ret, err) {
            console.log(JSON.stringify(ret));
            var result = ret.list[0].granted;
            var never = ret.never;
            if (never == true && result == false) {
                api.toast({
                    msg: '请在设置中打开读取存储空间的权限',
                });
                return false;
            }
            if (result == false) {
                return false;
            }
            return true;
        });
    }
    if (has2) {
        return true;
    }
}

function uploadHeadPic(fn) {

    api.actionSheet({
        title: '选择上传方式',
        cancelTitle: '取消',
        buttons: ['拍照', '手机相册']
    }, function (ret, err) {
        if (ret) {
            if (ret.buttonIndex == 1) {
                if (hasPermissions_camas()) {
                    takePicture(fn)
                } else {
                    if (hasPermissions_camas()) {
                        takePicture(fn)
                    }
                }

            } else if (ret.buttonIndex == 2) {
                if (hasPermissions_hasPermissions()) {
                    getStoragePic(fn);
                } else {
                    if (hasPermissions_hasPermissions()) {
                        getStoragePic(fn);
                    }
                }

            }
        }
    });
}

//保存剪辑图像
function uploadImg(path, fn, type) {
    var img = new Image();
    img.src=path;
    img.onload=function(){
        api.showProgress({
            title: '上传中...',
            text: '请稍等...',
        });
        //上传剪辑后的图像到服务器
        api.ajax({
            url: ajaxUrl + Interface.upload_img,
            //这里是我们约定好的后台上传图片的位置 ，你可以根据你的需求来改
            method: 'post',
            cache: 'false',
            timeout: 30,
            dataTpye: 'json',
            data: {
                files: {
                    file: path
                },
                values:{
                    imgWidth:img.width,
                    imgHight:img.height
                }
            }
        }, function (ret, err) {

            console.log(JSON.stringify(ret));

            api.hideProgress();
            if (ret.code == 200) {
                if(type == 1){

                }else {
                    api.toast({
                        msg: '上传成功'
                    });
                }
                fn(ret);

            }
            //上传进度
            if (ret.code == 201) {
                api.toast({
                    msg: '上传错误',
                    duration: 3000,
                    location: 'bottom'
                });
            }
        });
    }

}


//拍照
function takePicture(fn) {
    api.getPicture({
        sourceType: 'camera',
        encodingType: 'jpg',
        mediaValue: 'pic',
        destinationType: 'url',
        allowEdit: false,
        quality: 100,
        saveToPhotoAlbum: false
    }, function (ret, err) {
        //  alert(JSON.stringify(ret));
        if (ret) {
            uploadImg(ret.data, fn);
        } else {
            api.toast({
                msg: '图像获取失败',
                duration: 3000,
                location: 'bottom'
            });
        }
    });
}

//手机相册选图片
function getStoragePic(fn) {
    api.getPicture({
        sourceType: 'library',
        encodingType: 'png',
        mediaValue: 'pic',
        destinationType: 'url',
        allowEdit: true,
        quality: 100,
        preview: true,
        saveToPhotoAlbum: false
    }, function (ret, err) {
        //  alert(JSON.stringify(ret.data));
        if (ret) {
            uploadImg(ret.data, fn);
        } else {
            api.toast({
                msg: '图像获取失败',
                duration: 3000,
                location: 'bottom'
            });
        }
    });
}


//版本更新
function checkUpdate() {

    var mam = api.require('mam');
    mam.checkUpdate(function(ret, err) {
        if (ret) {
            var Apptypetext1 = "";
            var Apptypetext2 = "";
            var Apptypetext3 = "";
            var Apptypetext4 = "";
            var Apptypetext5 = "";
            var Apptypetext6 = "";
            var Apptypetext7 = "";
            var Apptypetext8 = "";
            Apptypetext1 = "新版本型号:";
            Apptypetext2 = "更新提示语:";
            Apptypetext3 = "下载地址:";
            Apptypetext4 = "发布时间:";
            Apptypetext5 = "有新的版本,是否下载并安装";
            Apptypetext6 = "确定";
            Apptypetext7 = "取消";
            Apptypetext8 = "正在下载应用";
            var result = ret.result;
            if (result.update == true && result.closed == false) {
                var str = Apptypetext1 + result.version + ';' + Apptypetext2 + result.updateTip + ';' + Apptypetext3 + result.source +
                    ';' + Apptypetext4 + result.time;
                api.confirm({
                    title: Apptypetext5,
                    msg: str,
                    buttons: [Apptypetext6, Apptypetext7]
                }, function(ret, err) {
                    if (ret.buttonIndex == 1) {
                        if (api.systemType == "android") {
                            api.download({
                                url: result.source,
                                report: true
                            }, function(ret, err) {
                                if (ret && 0 == ret.state) { /* 下载进度 */
                                    api.toast({
                                        msg: Apptypetext8 + ret.percent + "%",
                                        duration: 2000
                                    });
                                }
                                if (ret && 1 == ret.state) { /* 下载完成 */
                                    var savePath = ret.savePath;
                                    api.installApp({
                                        appUri: savePath
                                    });
                                }
                            });
                        }
                        if (api.systemType == "ios") {

                            api.installApp({
                                appUri: result.source
                            });
                        }
                    }
                });
            } else {
                console.log("暂无版本更新")
                /* api.alert({
                     msg : "暂无更新"
                 }); */
            }
        } else {
// 			api.alert({
// 				msg: err.msg
// 			});
        }
    });
}

//获取版本号
function getversion(fn) {
    var platform = 1;
    var sysType = api.systemType;
    if (sysType == 'ios') {
        platform = 2;
    } else if (sysType == 'android') {
        platform = 1;
    }
    getAjax(Interface.check_version, {type: platform}, function (res) {
        console.log(1111111111)
        console.log(Interface.check_version)
        console.log(jsonChange(res))
        console.log(1111111111)
        fn(res);
    }, function (res, err) {
    })
}



function anroidDown(url) {
    api.download({
        url: url,
        report: true
    }, function (ret, err) {
        if (ret && 0 == ret.state) { /* 下载进度 */
            api.toast({
                msg: Apptypetext8 + ret.percent + "%",
                duration: 2000
            });
        }
        if (ret && 1 == ret.state) { /* 下载完成 */
            var savePath = ret.savePath;
            api.installApp({
                appUri: savePath
            });
        }
    });
}

function iosDown(url) {
    api.installApp({
        // appUri: url
        appUri: 'https://itunes.apple.com/cn/app/id1477929674'
    });
}


//导航页监听 禁止返回
function keybackListener() {

    api.addEventListener({
        name: 'keyback'
    }, function(ret, err){

        comeBack();

    });

}


//返回首页
function BankIndex() {
    var ci = 0;
    var time1, time2;
    api.addEventListener({
        name: 'keyback'
    }, function (ret, err) {
        if (ci == 0) {
            time1 = new Date().getTime();
            ci = 1;
            api.toast({msg: '再按一次返回键放弃支付'});
        } else if (ci == 1) {
            time2 = new Date().getTime();
            if (time2 - time1 < 3000) {
                openWin('index', 'index.html')
            } else {
                ci = 0;
                api.toast({msg: '再按一次返回键放弃支付'});
            }
        }
    });
}

//返回首页
var ci = 0;
var time1, time2;

function BankIndexBtn() {
    console.log(ci);
    if (ci == 0) {
        time1 = new Date().getTime();
        ci = 1;
        console.log(ci);
        api.toast({msg: '再按一次返回键放弃支付'});
    } else if (ci == 1) {
        time2 = new Date().getTime();
        if (time2 - time1 < 3000) {
            openWin('index', 'index.html')
        } else {
            ci = 0;
            api.toast({msg: '再按一次返回键放弃支付'});
        }
    }
}

//退出APP
function ExitApp() {
    var ci = 0;
    var time1, time2;
    api.addEventListener({
        name: 'keyback'
    }, function (ret, err) {
        if (ci == 0) {
            time1 = new Date().getTime();
            ci = 1;
            api.toast({msg: '再按一次返回键退出'});

        } else if (ci == 1) {
            time2 = new Date().getTime();
            if (time2 - time1 < 3000) {
                api.closeWidget({
                    id: api.appId,
                    retData: {
                        name: 'closeWidget'
                    },
                    silent: true
                });
            } else {
                ci = 0;
                api.toast({msg: '再按一次返回键退出'});
            }
        }
    });
}


function UrlNoAnimation(path, param) {
    var pathArr = path.split('/');
    var pathName = pathArr[pathArr.length - 1];
    console.log('当前链接路径：' + jsonChange(path) + '，跳转传参：' + JSON.stringify(param));
    if (isDefine(param)) {
        api.openWin({
            name: pathName,
            url: path + '.html',
            // reload: true,
            slidBackEnabled: true,
            // softInputMode: 'pan',
            allowEdit: true,
            animation: {
                type:"none"
            },
            pageParam: param
        });
    } else {
        api.openWin({
            name: pathName,
            url: path + '.html',
            // reload: true,
            slidBackEnabled: true,
            // softInputMode: 'pan',
            allowEdit: true,
            animation: {
                type:"none"
            },
            pageParam: {

            }
        });
    }
}

//后退功能
function comeBack(type) {
    api.historyBack({}, function (ret, err) {
        if (!ret.status) {
            api.closeWin();
            //type 1是白色背景，2是透明背景
            // var arr = jsonChange($api.getStorage('beforePath'));
            var arr = JSON.parse(jsonChange($api.getStorage('beforePath')));
            var path = arr[arr.length-1];
            arr.pop()
            console.log('被移出的元素：'+path);
            $api.setStorage('beforePath',arr);
            console.log('移出后的数组：'+ jsonChange($api.getStorage('beforePath')));
            var currPath = arr[arr.length-1];
            var pathArr = ['circle_index','person_index','department_index','member','activity_index','match_basketball','match_football','match_detail','team_member','team_match_detail','team_detail'];
            var index = $.inArray(currPath,pathArr);
            if(index >= 0){
                $api.fixStatusBar($api.dom('#header'));
                api.setStatusBarStyle({
                    style: 'light', //设置APP状态栏字体色
                    color: 'rgba(255,255,255,0)', //设置APP状态栏背景色
                });
            }else {
                setFixStatusBar(); //设置状态栏
            }
            api.sendEvent({
                name: 'listenStatusBar',
            });
        }
    });
}


//公用跳转 - 可右滑返回 - 仅支持ios
function commonUrl(path, param,reload) {
    if(!isDefine(path)){
        return;
    }
    var pathArr = path.split('/');
    var pathName = pathArr[pathArr.length - 1];
    console.log('当前链接路径：' + jsonChange(path) + '，跳转传参：' + JSON.stringify(param));
    var currArr =  $api.getStorage('beforePath');
    if (isDefine(param)) {
        if (reload == 1){
            api.openWin({
                name: pathName,
                url: path + '.html',
                reload: true,
                slidBackEnabled: true,
                // softInputMode: 'pan',
                allowEdit: true,
                pageParam: param
            });
        } else {
            api.openWin({
                name: pathName,
                url: path + '.html',
                // reload: true,
                slidBackEnabled: true,
                // softInputMode: 'pan',
                allowEdit: true,
                pageParam: param
            });
        }

        currArr.push(pathName)
        $api.setStorage('beforePath',currArr);
        console.log(jsonChange($api.getStorage('beforePath')))
    } else {
        api.openWin({
            name: pathName,
            url: path + '.html',
            // reload: true,
            slidBackEnabled: true,
            // softInputMode: 'pan',
            allowEdit: true,
            pageParam: {

            }
        });
        currArr.push(pathName)
        $api.setStorage('beforePath',currArr);
        console.log(jsonChange($api.getStorage('beforePath')))
    }

}

//公用跳转 - 禁止右滑返回 - 仅支持ios
function individualUrl(path, param) {

    var pathArr = path.split('/');
    var pathName = pathArr[pathArr.length - 1];
    console.log('当前链接路径：' + jsonChange(path) + '，跳转传参：' + JSON.stringify(param));
    if (isDefine(param)) {
        api.openWin({
            name: pathName,
            url: path + '.html',
            reload: true,
            slidBackEnabled: false,
            // softInputMode: 'pan',
            allowEdit: true,
            pageParam: param
        });
    } else {
        api.openWin({
            name: pathName,
            url: path + '.html',
            reload: true,
            slidBackEnabled: false,
            // softInputMode: 'pan',
            allowEdit: true,
            pageParam: {}
        });
    }
}

function toLinks(path) {
    var pathArr = path.split('/');
    var pathName = pathArr[pathArr.length - 1];
    console.log('当前链接路径：' + jsonChange(path));
    api.openWin({
        name: pathName,
        url: path + '.html',
        reload: true,
        slidBackEnabled: false,
        pageParam: {},
        animation: {
            type: 'none'
        }
    });
}

//无数据
var noData = '<div class="no-data">' +
    '            <div class="data-img">' +
    '                <p>暂时只有Uni陪你哦~</p>' +
    '            </div>' +
    '        </div>';
//无网络
var noWeb = '<div class="no-web">' +
    '            <div class="web-img">' +
    '                <p>uni被网络打败了...</p>' +
    '                <a href="javascript:void(0);" tapmode onclick="reloadView();">点击刷新</a>' +
    '            </div>' +
    '        </div>';

//公共弹窗
function commonPopup(text) {
    var tips_txt = '<section class="common-mask-pop on">' +
        '        <div class="common-mask" style="display: block"></div>' +
        '        <div class="common-msg-pop">' +
        '            <div class="msg-pop-title">提示</div>' +
        '            <div class="msg-pop-content">' + text + '</div>' +
        '            <div class="common-mask-btn" onclick="popupClose();">知道了</div>' +
        '        </div>' +
        '    </section>'
    $('body').append(tips_txt);
    setTimeout(function () {
        popupClose()
    }, 3000)
}

//关闭公共弹窗
function popupClose() {
    $(".common-mask").hide();
    $(".common-mask-pop").removeClass("on");
}


//统计字符串长度
function getLength(dom) {
    /*var str = document.getElementById("str");
    var str1 = str.value;*/
    var str1 = dom;
    // var str1 = str.val();
    ///<summary>获得字符串实际长度，中文2，英文1</summary>
    ///<param name="str">要获得长度的字符串</param>
    var realLength = 0, len = str1.length, charCode = -1;
    for (var i = 0; i < len; i++) {
        charCode = str1.charCodeAt(i);
        if (charCode >= 0 && charCode <= 128) {
            realLength += 1;
        } else {
            realLength += 2;
        }
    }
    return realLength;
};


//刷新页面
function reloadView() {
    window.location.reload();
}


/* ---------------------------------- */
/* 跳转公共方法*/

//活动报名
function signAct(path) {
    var pathArr = path.split('/');
    var pathName = pathArr[pathArr.length - 1];
    console.log('当前链接路径：' + jsonChange(path) + '，跳转传参：activity_id:' + activity_id);
    api.openWin({
        name: pathName,
        url: path + '.html',
        reload: true,
        pageParam: {
            activity_id: activity_id
        }
    });
}

//取消活动
function cancelAct(id, fn) {
    var param = {
        token: $api.getStorage('token'),
        activity_id: id
    }
    getAjax(Interface.activity_cancel, param, function (res) {
        fn(res);
    }, function (error) {
        pop.notice(error.msg)
        pop.close();
    })
}

//取消活动报名
function cancelSign(id, fn) {
    var param = {
        token: $api.getStorage('token'),
        activity_id: id
    }
    getAjax(Interface.activity_out, param, function (res) {
        fn(res);

    }, function (error) {
        pop.notice(error.msg)
        pop.close();
    })
}

//点赞、取消点赞
function fabulous(stype, type, pid, fn) {
    var param = {
        token: $api.getStorage('token'),
        stype: stype,
        type: type,
        pid: pid,
    }
    console.log(jsonChange(param))
    getAjax(Interface.news_fabulous, param, function (res) {
        fn(res);
    }, function (error) {
        pop.notice(error.msg)
        pop.close();
    })
}

//关注、取消关注会员或者圈子
function follow(stype, type, pid, fn, fnError) {
    var param = {
        token: $api.getStorage('token'),
        stype: stype,//1为关注，2为取消关注
        type: type,//1为会员，2为圈子
        pid: pid,//会员id，圈子id
    }
    getAjax(Interface.follow, param, function (res) {
        fn(res);
        api.sendEvent({
            name: 'memberInfo',
            extra: {}
        });
    }, function (error) {
        fnError(error)
        pop.notice(error.msg);
        pop.close();
    })
}

//收藏
function collection(type, pid, fn) {
    var param = {
        token: $api.getStorage('token'),
        type: type,//类型：1新闻 2帖子 3活动 4评论
        pid: pid,//根据type来，type为1就是新闻id
    }
    getAjax(Interface.collection, param, function (res) {
        fn(res);
        api.sendEvent({
            name: 'memberInfo',
            extra: {}
        });
    }, function (error) {
        pop.notice(error.msg);
        pop.close();
    })
}

//取消收藏
function collection_cancel(type, pid, fn) {
    var param = {
        token: $api.getStorage('token'),
        type: type,//类型：1新闻 2帖子 3活动 4评论
        pid: pid,//根据type来，type为1就是新闻id
    }
    getAjax(Interface.collection_cancel, param, function (res) {
        fn(res);
        api.sendEvent({
            name: 'memberInfo',
            extra: {}
        });
    }, function (error) {
        pop.notice(error.msg)
        pop.close();
    })
}


function getImg(url) {
    return ajaxUrl + url;
}


function confirmBox(title, msg, yes) {
    api.confirm({
        title: title,
        msg: msg,
        buttons: ['确定', '取消']
    }, function (ret, err) {
        var index = ret.buttonIndex;
        if (index == 1) {
            yes();
        }
    });
}

//微信登录
function wxLogin(fn) {
    var wx = api.require('wxPlus');
    wx.isInstalled(function (ret, err) {
        if (!ret.installed) {
            pop.notice("当前设备未安装微信客户端");
        } else {
            wx.auth({
                apiKey: 'wxfb13dbd49aecdd98'
            }, function (ret, err) {
                if (ret.status) {
                    wx.getToken({
                        apiKey: 'wxfb13dbd49aecdd98',
                        apiSecret: '086d1ad3097c7d3e3b124668774a297c',
                        code: ret.code
                    }, function (ret, err) {
                        console.log(JSON.stringify(ret));
                        if (ret.status) {
                            api.showProgress({
                                style: 'default',
                                animationType: 'fade',
                                title: '授权成功',
                                text: '绑定处理中...',
                                modal: true
                            });
                            wx.getUserInfo({
                                accessToken: ret.accessToken,
                                openId: ret.openId
                            }, function (ret, err) {
                                console.log(JSON.stringify(ret));
                                console.log(JSON.stringify(err));
                                if (ret.status) {
                                    // 绑定成功
                                    fn(ret);
                                }
                            });
                        } else {
                            //alert(err.code);
                        }
                    });
                }
            });
        }
    });
}

//QQ登录
function QQLogin(fn) {
    var qq = api.require('QQPlus');
    qq.installed(function (ret, err) {
        if (!ret.status) {
            pop.notice("当前设备未安装QQ客户端");
        } else {
            qq.login({}, function (ret, err) {
                console.log(jsonChange(ret));
                if (ret.status) {
                    fn(ret);
                }
            });
        }
    });
}

//微博登录
function WeiBoLogin(fn) {
    var weiboPlus = api.require('weiboPlus');
    weiboPlus.isInstalled(function (ret, err) {
        if (!ret.status) {
            pop.notice("当前设备未安装微博客户端");
        } else {
            weiboPlus.auth({}, function (ret, err) {
                console.log(jsonChange(ret));
                // alert(jsonChange(ret));
                if (ret.status) {
                    fn(ret);
                }
            });
        }
    });
}


//清理缓存
function clearCache() {
    pop.loading();
    api.clearCache(function () {
        setTimeout(function () {
            pop.close();
            pop.notice('清除完成');
        }, 2500);
    });
};

//获取缓存
function getCacheSize(fn) {
    var dw = 'B';
    var size = 0;
    api.getCacheSize(function (ret, err) {
        dw = 'B';
        size = parseInt(ret.size);
        if (size > 1024) {
            dw = "kb";
            size = parseInt(size / 1024);
            if (size > 1024) {
                dw = "M";
                size = parseInt(size / 1024);
            }
        }
        fn(size + dw)

    });
}


//新闻
function newsList(item) {
    var html = '';
    if (!isDefine(item)) {
        return true;
    }


    var news_id = {'news_id': item.id};
    var label_id = {"tips_id": item.label_id}
    html += '<li>';
    html += '<div class="video-detail" onclick=\'commonUrl("../index/news_detail",' + jsonChange(news_id) + ')\'>';
    html += '<h6 class="news-title multiline-ellipsis_3">' + item.title + '</h6>';
    var icons_path = item.icon_path;
    var icons_pathHtml = '';
    $.each(icons_path, function (j, jtem) {
        icons_pathHtml += '<div class="img bg-cover" style="background-image: url(' + getImg(jtem) + ');"></div>';
    })
    if (icons_path.length == 3) {
        html += '<div class="detail-img-list">';
        html += icons_pathHtml;
        html += '</div>';
    } else if (icons_path.length == 2) {
        html += '<div class="detail-img-list two-img">';
        html += icons_pathHtml;
        html += '</div>';
    } else {
        html += '<div class="video-box bg-cover" style="background-image: url(' + getImg(icons_path[0]) + ')";></div>';
    }
    html += '<div class="detail-bottom">';
    html += '<div class="bottom-tips">';
    if (item.recommend == 1) {
        html += '<span class="bt-pd toUp">精选</span>';
    }
    html += '<span class="bt-pd tips"tapmode onclick=\'commonUrl("../index/news_list",' + jsonChange(label_id) + ')\'>#' + item.circle_title + '#</span>';
    html += '</div>';
    html += '<div class="bottom-hot">' + item.hot_number + '</div>';
    html += '</div>';
    html += '</div>';
    html += '</li>';

    return html;
}

//帖子
function tiesList(jtem,shield_type) {
    var item = jtem;
    var html = '';
    if (!isDefine(item)) {
        return;
    }
    var userInfo = $api.getStorage('userInfo');
    var userData = item.member;
    console.log();
    var badgeList = '';//徽章列表
    if (isDefine(userData.badge_path)) {
        for (var k = 0; k < userData.badge_path.length; k++) {
            if (k <= 5) {
                badgeList += '<dd class="icon"><img src="' + getImg(userData.badge_path[k]) + '" alt=""></dd>'
            }
        }
    }
    var invitation_id = {'invitation_id': item.id};
    var member_id = {'member_id': userData.id};
    var circleP = {"circle_id": item.circle_id}
    var userVip = '';
    if(isDefine(userData.attestation_status)){
        if(userData.attestation_status == 2){
            userVip = '<span class="vip"></span>';
        }
    }

    html += '<li>';
    html += '<div class="common-user-detail">';
    html += '<div class="user-info"tapmode onclick=\'commonUrl("../activity/person_index",' + jsonChange(member_id) + ')\'>';
    html += '<div class="userRelative"><div class="user-icon bg-cover" style="background-image: url(' + getImg(userData.icon_path) + ');"></div>'+userVip+'</div>';
    html += '<div class="info">';
    html += '<div class="name">';
    html += '<h6>' + userData.name + '</h6>';
    html += '<dl class="badge-list" tapmode onclick="toBadgePage(event)">';
    html += badgeList;
    html += '</dl>';
    html += '</div>';
    html += '<span class="time">' + item.date + '</span>';
    html += '</div>';
    html += '</div>';
    if (userInfo.id != userData.id) {
        if (item.member_follow == '0') {
            html += '<div class="follow" tapmode onclick="followAction(1,' + userData.id + ')">';
            html += '<span class="followed">已关注</span>';
            html += '<span class="no-follow">关注</span>';
            html += '</div>';
        } else {
            html += '<div class="follow on" tapmode onclick="followAction(2,' + userData.id + ')">';
            html += '<span class="no-follow">关注</span>';
            html += '<span class="followed">已关注</span>';
            html += '</div>';
        }
    }
    html += '</div>';
    html += '<div class="video-detail" onclick=\'commonUrl("../circle/invite_detail",' + jsonChange(invitation_id) + ')\'>';
    var article = '';
    if (isDefine(item.title)){
        if (isDefine(item.content_info)){
            article = '<div style="word-break: break-all;" class="multiline-ellipsis f26 mb10 c-666">'+item.content_info+'</div>';
        }
    }else {
        item.title = item.content_info;

    }
    html += '<h6 class="news-title multiline-ellipsis_3">' + item.title + '</h6>'+ article;
    // html += '<div class="multiline-ellipsis_4 pb10">' + item.brief + '</div>';
    var icons_path = item.icons_path;
    var icons_pathHtml = '';
    if(isDefine(item.void_path)){
        html +='<div class="video-box bg-cover" style="background-image: url(' + ajaxUrl + item.void_icon_path + ')";>' +
        '                 <p class="single-ellipsis"></p>' +
        '                 <span class="icon-play"></span>' +
        '                 <span class="time"></span>' +
        '              </div>';
    }else {
        if (isDefine(icons_path)) {
            $.each(icons_path, function (j, jtem) {
                if(j<3){
                    icons_pathHtml += '<div class="img bg-cover" style="background-image: url(' + getImg(jtem) + ');"></div>';
                }
            })
            if (icons_path.length >= 3) {
                html += '<div class="detail-img-list">';
                html += icons_pathHtml;
                html += '</div>';
            } else if (icons_path.length == 2) {
                html += '<div class="detail-img-list two-img">';
                html += icons_pathHtml;
                html += '</div>';
            } else if (icons_path.length == 1) {
                html += '<div class="video-box bg-cover" style="max-height: 6rem; padding-left: 0; padding-right: 0; justify-content: flex-start;"><img src="' + ajaxUrl + item.icons_path[0] + '" alt=""></div>';
            } else {
                html += '';
            }
        }
    }

    html += '<div class="detail-bottom">';
        html += '<div class="bottom-tips">';
        if (item.recommend == 1) {
            html += '<span class="bt-pd toUp">精选</span>';
        }
        if(isDefine(item.circle_title)){
            html += '<span class="bt-pd tips" tapmode onclick=\'commonUrl("../circle/circle_index",' + jsonChange(circleP) + ')\'>#' + item.circle_title + '#</span>';
        }else {
            html += '<span class="bt-pd "></span>';
        }
        html += '</div>';
        if(shield_type == 2){
            html += '<div class="cancel-shield" tapmode onclick=\'cancelShield('+item.id+',2,this,event)\'>移出屏蔽</div>';
        }else {
            html += '<div class="bottom-hot">' + item.hot_number + '</div>';
        }
    html += '</div>';
    html += '</div>';
    html += '</li>';
    return html;
}


//微信分享分享
function wxpyqFX(param,shareStatus) {
    var wx = api.require('wxPlus');
    console.log(jsonChange(param))
    wx.shareWebpage(param, function (ret, err) {
        console.log(jsonChange(ret))
        if (ret.status) {
            pop.notice('分享成功');
            if(shareStatus){
                if(shareStatus == 1){
                    shareSuccess()
                }
            }

        } else {
            pop.notice('分享失败');
        }
    });
}


//qq分享
function qqfx(param,shareStatus) {
    var qq = api.require('QQPlus');
    qq.shareNews(param, function (ret, err) {
        console.log(jsonChange(ret))
        if (ret.status) {
            pop.notice('分享成功');
            if(shareStatus){
                if(shareStatus == 1){
                    shareSuccess()
                }
            }
        } else {
            pop.notice('分享失败');
        }
    });
}

//微博分享
function weibo_authorize(param,shareStatus) {
    var weiboPlus = api.require('weiboPlus');
    weiboPlus.shareWebPage(param, function (ret, err) {

        if (ret.status) {
            pop.notice('分享成功');
            if(shareStatus){
                if(shareStatus == 1){
                    shareSuccess()
                }
            }
        }else {
            pop.notice('分享成功');
        }
    });
}


//播放视频
function play(videoUrl,title) {
    var module = api.require('easyVideoPlayer');
    console.log(videoUrl)
    var param = {
        msg : videoUrl
    };
    module.playVideo(param);
}


//赛事 金字塔

function matchList(data,type) {

    var areaMatch = '';
    var arr1 = [], arr2 = [], arr3 = [];
    $.each(data, function (i, item) {
        if (isDefine(item.title)) {
            if (item.title != '决赛') {
                var a1 = [], a2 = [];
                $.each(item.data, function (j, jtem) {
                    if(jtem.up_dow == 1){
                        a1.push(jtem);
                    }else {
                        a2.push(jtem);
                    }
                });
                arr1.push(a1);
                arr2.push(a2);
            } else {
                arr3 = item.data;
                console.log(jsonChange(arr3))
            }
        }
    });

    //正
    $.each(arr1, function (i, item) {
        if (item.length == 4) {
            var html = '';
            for (var j = 0; j < item.length; j++) {
                var jtem = item[j];
                var teamParam1 = {"team_id": jtem.team_one_data.id};//左侧队伍id
                var teamParam2 = {"team_id": jtem.team_two_data.id};//右侧队伍id
                if (jtem.chang_type == 1) {
                    if (Number(jtem.team_one_data.team_one_fen1) > Number(jtem.team_two_data.team_two_fen1)) {
                        var chang = '<p><em class="win">' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else if (Number(jtem.team_one_data.team_one_fen1) < Number(jtem.team_two_data.team_two_fen1)) {
                        var chang = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else {
                        var chang = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    }
                } else {
                    if (Number(jtem.team_one_data.team_one_fen1) > Number(jtem.team_two_data.team_two_fen1)) {
                        var chang1 = '<p><em class="win">' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else if (Number(jtem.team_one_data.team_one_fen1) < Number(jtem.team_two_data.team_two_fen1)) {
                        var chang1 = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else {
                        var chang1 = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    }

                    if (Number(jtem.team_one_data.team_one_fen2) > Number(jtem.team_two_data.team_two_fen2)) {
                        var chang2 = '<p><em class="win">' + jtem.team_one_data.team_one_fen2 + '</em>:<em>' + jtem.team_two_data.team_two_fen2 + '</em></p>';
                    } else if (Number(jtem.team_one_data.team_one_fen2) < Number(jtem.team_two_data.team_two_fen2)) {
                        var chang2 = '<p><em>' + jtem.team_one_data.team_one_fen2 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen2 + '</em></p>';
                    } else {
                        var chang2 = '<p><em>' + jtem.team_one_data.team_one_fen2 + '</em>:<em>' + jtem.team_two_data.team_two_fen2 + '</em></p>';
                    }
                    var chang = chang1 + chang2;
                }
                html += '<div class="flex-li">' +
                    '                            <div class="flex-match">' +
                    '                                <div class="flex-match-school" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam1) + ')\'>' +
                    '                                    <h6 class="school-icon  bg-cover"' +
                    '                                        style="background: url(' + ajaxUrl + jtem.team_one_data.icon_path + ')"></h6>' +
                    '                                    <p>' + jtem.team_one_data.title + '</p>' +
                    '                                </div>' +
                    '                                <div class="flex-match-school" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam2) + ')\'>' +
                    '                                    <h6 class="school-icon  bg-cover"' +
                    '                                        style="background: url(' + ajaxUrl + jtem.team_two_data.icon_path + ')"></h6>' +
                    '                                    <p>' + jtem.team_two_data.title + '</p>' +
                    '                                </div>' +
                    '                            </div>' +
                    '                            <div class="flex-match-score">' + chang + '</div>' +
                    '                        </div>';


            }
            areaMatch += '<li class="flex8">' + html + '</li>';
        } else if (item.length == 2) {
            var html = '';
            for (var j = 0; j < item.length; j++) {
                var jtem = item[j];
                var teamParam1 = {"team_id": jtem.team_one_data.id};//左侧队伍id
                var teamParam2 = {"team_id": jtem.team_two_data.id};//右侧队伍id
                if (jtem.chang_type == 1) {
                    if (Number(jtem.team_one_data.team_one_fen1) > Number(jtem.team_two_data.team_two_fen1)) {
                        var chang = '<p><em class="win">' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else if (Number(jtem.team_one_data.team_one_fen1) < Number(jtem.team_two_data.team_two_fen1)) {
                        var chang = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else {
                        var chang = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    }
                } else {
                    if (Number(jtem.team_one_data.team_one_fen1) > Number(jtem.team_two_data.team_two_fen1)) {
                        var chang1 = '<p><em class="win">' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else if (Number(jtem.team_one_data.team_one_fen1) < Number(jtem.team_two_data.team_two_fen1)) {
                        var chang1 = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else {
                        var chang1 = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    }

                    if (Number(jtem.team_one_data.team_one_fen2) > Number(jtem.team_two_data.team_two_fen2)) {
                        var chang2 = '<p><em class="win">' + jtem.team_one_data.team_one_fen2 + '</em>:<em>' + jtem.team_two_data.team_two_fen2 + '</em></p>';
                    } else if (Number(jtem.team_one_data.team_one_fen2) < Number(jtem.team_two_data.team_two_fen2)) {
                        var chang2 = '<p><em>' + jtem.team_one_data.team_one_fen2 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen2 + '</em></p>';
                    } else {
                        var chang2 = '<p><em>' + jtem.team_one_data.team_one_fen2 + '</em>:<em>' + jtem.team_two_data.team_two_fen2 + '</em></p>';
                    }
                    var chang = chang1 + chang2;
                }
                html += '<div class="flex-li">' +
                    '                            <div class="flex-match">' +
                    '                                <div class="flex-match-school" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam1) + ')\'>' +
                    '                                    <h6 class="school-icon  bg-cover"' +
                    '                                        style="background: url(' + ajaxUrl + jtem.team_one_data.icon_path + ')"></h6>' +
                    '                                    <p>' + jtem.team_one_data.title + '</p>' +
                    '                                </div>' +
                    '                                <div class="flex-match-school" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam2) + ')\'>' +
                    '                                    <h6 class="school-icon  bg-cover"' +
                    '                                        style="background: url(' + ajaxUrl + jtem.team_two_data.icon_path + ')"></h6>' +
                    '                                    <p>' + jtem.team_two_data.title + '</p>' +
                    '                                </div>' +
                    '                            </div>' +
                    '                            <div class="flex-match-score">' + chang + '</div>' +
                    '                        </div>';


            }
            areaMatch += '<li class="flex4">' + html + '</li>';
        } else if (item.length == 1) {
            var html = '';
            for (var j = 0; j < item.length; j++) {
                var jtem = item[j];
                var teamParam1 = {"team_id": jtem.team_one_data.id};//左侧队伍id
                var teamParam2 = {"team_id": jtem.team_two_data.id};//右侧队伍id
                if (jtem.chang_type == 1) {
                    if (Number(jtem.team_one_data.team_one_fen1) > Number(jtem.team_two_data.team_two_fen1)) {
                        var chang = '<p><em class="win">' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else if (Number(jtem.team_one_data.team_one_fen1) < Number(jtem.team_two_data.team_two_fen1)) {
                        var chang = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else {
                        var chang = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    }
                } else {
                    if (Number(jtem.team_one_data.team_one_fen1) > Number(jtem.team_two_data.team_two_fen1)) {
                        var chang1 = '<p><em class="win">' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else if (Number(jtem.team_one_data.team_one_fen1) < Number(jtem.team_two_data.team_two_fen1)) {
                        var chang1 = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else {
                        var chang1 = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    }

                    if (Number(jtem.team_one_data.team_one_fen2) > Number(jtem.team_two_data.team_two_fen2)) {
                        var chang2 = '<p><em class="win">' + jtem.team_one_data.team_one_fen2 + '</em>:<em>' + jtem.team_two_data.team_two_fen2 + '</em></p>';
                    } else if (Number(jtem.team_one_data.team_one_fen2) < Number(jtem.team_two_data.team_two_fen2)) {
                        var chang2 = '<p><em>' + jtem.team_one_data.team_one_fen2 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen2 + '</em></p>';
                    } else {
                        var chang2 = '<p><em>' + jtem.team_one_data.team_one_fen2 + '</em>:<em>' + jtem.team_two_data.team_two_fen2 + '</em></p>';
                    }
                    var chang = chang1 + chang2;
                }
                html += '<div class="flex-li">' +
                    '                            <div class="flex-match">' +
                    '                                <div class="flex-match-school" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam1) + ')\'>' +
                    '                                    <h6 class="school-icon  bg-cover"' +
                    '                                        style="background: url(' + ajaxUrl + jtem.team_one_data.icon_path + ')"></h6>' +
                    '                                    <p>' + jtem.team_one_data.title + '</p>' +
                    '                                </div>' +
                    '                                <div class="flex-match-school" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam2) + ')\'>' +
                    '                                    <h6 class="school-icon  bg-cover"' +
                    '                                        style="background: url(' + ajaxUrl + jtem.team_two_data.icon_path + ')"></h6>' +
                    '                                    <p>' + jtem.team_two_data.title + '</p>' +
                    '                                </div>' +
                    '                            </div>' +
                    '                            <div class="flex-match-score">' + chang + '</div>' +
                    '                        </div>';


            }
            areaMatch += '<li class="flex2">' + html + '</li>';
        }
    })

    //中间
    $.each(arr3, function (i, item) {
        var teamParam1 = {"team_id": item.team_one_data.id};//左侧队伍id
        var teamParam2 = {"team_id": item.team_two_data.id};//右侧队伍id
        var win1 = '', win2 = '';
        if (item.chang_type == 1) {
            if (Number(item.team_one_data.team_one_fen1) > Number(item.team_two_data.team_two_fen1)) {
                var chang = '<p><em class="win">' + Number(item.team_one_data.team_one_fen1) + '</em>:<em>' + Number(item.team_two_data.team_two_fen1) + '</em></p>';

                if(type == 2){
                    win1 = '<div class="win1"></div>'
                    win2 = '<div class="win2"></div>'
                }else if(type == 3){
                    win1 = '<div class="win1"></div>'
                }else {
                    win1 = '<div class="win"></div>'
                }
            } else if (Number(item.team_one_data.team_one_fen1) < Number(item.team_two_data.team_two_fen1)) {
                var chang = '<p><em>' + Number(item.team_one_data.team_one_fen1) + '</em>:<em class="win">' + Number(item.team_two_data.team_two_fen1) + '</em></p>';
                if(type == 2){
                    win2 = '<div class="win1"></div>'
                    win1 = '<div class="win2"></div>'
                }else if(type == 3){
                    win2 = '<div class="win1"></div>'
                }else {
                    win2 = '<div class="win"></div>'
                }
            } else {
                var chang = '<p><em>' + Number(item.team_one_data.team_one_fen1) + '</em>:<em>' + Number(item.team_two_data.team_two_fen1) + '</em></p>';
            }
        } else {
            if (Number(item.team_one_data.team_one_fen1) > Number(item.team_two_data.team_two_fen1)) {
                var chang1 = '<p><em class="win">' + Number(item.team_one_data.team_one_fen1) + '</em>:<em>' + Number(item.team_two_data.team_two_fen1) + '</em></p>';
            } else if (Number(item.team_one_data.team_one_fen1) < Number(item.team_two_data.team_two_fen1)) {
                var chang1 = '<p><em>' + Number(item.team_one_data.team_one_fen1) + '</em>:<em class="win">' + Number(item.team_two_data.team_two_fen1) + '</em></p>';
            } else {
                var chang1 = '<p><em>' + Number(item.team_one_data.team_one_fen1) + '</em>:<em>' + Number(item.team_two_data.team_two_fen1) + '</em></p>';
            }

            if (item.team_one_data.team_one_fen2 > item.team_two_data.team_two_fen2) {
                var chang2 = '<p><em class="win">' + item.team_one_data.team_one_fen2 + '</em>:<em>' + item.team_two_data.team_two_fen2 + '</em></p>';
            } else if (item.team_one_data.team_one_fen2 < item.team_two_data.team_two_fen2) {
                var chang2 = '<p><em>' + item.team_one_data.team_one_fen2 + '</em>:<em class="win">' + item.team_two_data.team_two_fen2 + '</em></p>';
            } else {
                var chang2 = '<p><em>' + item.team_one_data.team_one_fen2 + '</em>:<em>' + item.team_two_data.team_two_fen2 + '</em></p>';
            }
            var chang = chang1 + chang2;
        }
        areaMatch += '<li class="flex-centre">' +
            '                        <div class="flex-li">' +
            '                            <div class="flex-match">' +
            '                                <div class="flex-match-school" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam1) + ')\'>' +
            '                                    <h6 class="school-icon  bg-cover"' +
            '                                        style="background: url(' + ajaxUrl + item.team_one_data.icon_path + ')"></h6>' +
            '                                    <p>' + item.team_one_data.title + '</p>' + win1 +
            '                                </div>' +
            '                            </div>' +
            '                        </div>' +
            '                        <div class="flex-centre-score">' + chang + '</div>' +
            '                        <div class="flex-li">' +
            '                            <div class="flex-match">' +
            '                                <div class="flex-match-school" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam2) + ')\'>' +
            '                                    <h6 class="school-icon  bg-cover"' +
            '                                        style="background: url(' + ajaxUrl + item.team_two_data.icon_path + ')"></h6>' +
            '                                    <p>' + item.team_two_data.title + '</p>' + win2 +
            '                                </div>' +
            '                            </div>' +
            '                        </div>' +
            '                    </li>';
    });


    //反
    $.each(arr2.reverse(), function (i, item) {
        if (item.length == 4) {
            var html = '';
            for (var j = 0; j < item.length; j++) {
                var jtem = item[j];
                var teamParam1 = {"team_id": jtem.team_one_data.id};//左侧队伍id
                var teamParam2 = {"team_id": jtem.team_two_data.id};//右侧队伍id
                if (jtem.chang_type == 1) {
                    if (Number(jtem.team_one_data.team_one_fen1) > Number(jtem.team_two_data.team_two_fen1)) {
                        var chang = '<p><em class="win">' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else if (Number(jtem.team_one_data.team_one_fen1) < Number(jtem.team_two_data.team_two_fen1)) {
                        var chang = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else {
                        var chang = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    }
                } else {
                    if (Number(jtem.team_one_data.team_one_fen1) > Number(jtem.team_two_data.team_two_fen1)) {
                        var chang1 = '<p><em class="win">' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else if (Number(jtem.team_one_data.team_one_fen1) < Number(jtem.team_two_data.team_two_fen1)) {
                        var chang1 = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else {
                        var chang1 = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    }

                    if (Number(jtem.team_one_data.team_one_fen2) > Number(jtem.team_two_data.team_two_fen2)) {
                        var chang2 = '<p><em class="win">' + jtem.team_one_data.team_one_fen2 + '</em>:<em>' + jtem.team_two_data.team_two_fen2 + '</em></p>';
                    } else if (Number(jtem.team_one_data.team_one_fen2) < Number(jtem.team_two_data.team_two_fen2)) {
                        var chang2 = '<p><em>' + jtem.team_one_data.team_one_fen2 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen2 + '</em></p>';
                    } else {
                        var chang2 = '<p><em>' + jtem.team_one_data.team_one_fen2 + '</em>:<em>' + jtem.team_two_data.team_two_fen2 + '</em></p>';
                    }
                    var chang = chang1 + chang2;
                }
                html += '<div class="flex-li">' +
                    '                            <div class="flex-match-score">' + chang + '</div>' +
                    '                            <div class="flex-match">' +
                    '                                <div class="flex-match-school" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam1) + ')\'>' +
                    '                                    <h6 class="school-icon  bg-cover"' +
                    '                                        style="background: url(' + ajaxUrl + jtem.team_one_data.icon_path + ')"></h6>' +
                    '                                    <p>' + jtem.team_one_data.title + '</p>' +
                    '                                </div>' +
                    '                                <div class="flex-match-school" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam2) + ')\'>' +
                    '                                    <h6 class="school-icon  bg-cover"' +
                    '                                        style="background: url(' + ajaxUrl + jtem.team_two_data.icon_path + ')"></h6>' +
                    '                                    <p>' + jtem.team_two_data.title + '</p>' +
                    '                                </div>' +
                    '                            </div>' +
                    '                        </div>';

            }
            areaMatch += '<li class="flex8 down-area">' + html + '</li>';

        } else if (item.length == 2) {
            var html = '';
            for (var j = 0; j < item.length; j++) {
                var jtem = item[j];
                var teamParam1 = {"team_id": jtem.team_one_data.id};//左侧队伍id
                var teamParam2 = {"team_id": jtem.team_two_data.id};//右侧队伍id
                if (jtem.chang_type == 1) {
                    if (Number(jtem.team_one_data.team_one_fen1) > Number(jtem.team_two_data.team_two_fen1)) {
                        var chang = '<p><em class="win">' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else if (Number(jtem.team_one_data.team_one_fen1) < Number(jtem.team_two_data.team_two_fen1)) {
                        var chang = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else {
                        var chang = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    }
                } else {
                    if (Number(jtem.team_one_data.team_one_fen1) > Number(jtem.team_two_data.team_two_fen1)) {
                        var chang1 = '<p><em class="win">' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else if (Number(jtem.team_one_data.team_one_fen1) < Number(jtem.team_two_data.team_two_fen1)) {
                        var chang1 = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else {
                        var chang1 = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    }

                    if (Number(jtem.team_one_data.team_one_fen2) > Number(jtem.team_two_data.team_two_fen2)) {
                        var chang2 = '<p><em class="win">' + jtem.team_one_data.team_one_fen2 + '</em>:<em>' + jtem.team_two_data.team_two_fen2 + '</em></p>';
                    } else if (Number(jtem.team_one_data.team_one_fen2) < Number(jtem.team_two_data.team_two_fen2)) {
                        var chang2 = '<p><em>' + jtem.team_one_data.team_one_fen2 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen2 + '</em></p>';
                    } else {
                        var chang2 = '<p><em>' + jtem.team_one_data.team_one_fen2 + '</em>:<em>' + jtem.team_two_data.team_two_fen2 + '</em></p>';
                    }
                    var chang = chang1 + chang2;
                }
                html += '<div class="flex-li">' +
                    '                            <div class="flex-match-score">' + chang + '</div>' +
                    '                            <div class="flex-match">' +
                    '                                <div class="flex-match-school" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam1) + ')\'>' +
                    '                                    <h6 class="school-icon  bg-cover"' +
                    '                                        style="background: url(' + ajaxUrl + jtem.team_one_data.icon_path + ')"></h6>' +
                    '                                    <p>' + jtem.team_one_data.title + '</p>' +
                    '                                </div>' +
                    '                                <div class="flex-match-school" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam2) + ')\'>' +
                    '                                    <h6 class="school-icon  bg-cover"' +
                    '                                        style="background: url(' + ajaxUrl + jtem.team_two_data.icon_path + ')"></h6>' +
                    '                                    <p>' + jtem.team_two_data.title + '</p>' +
                    '                                </div>' +
                    '                            </div>' +
                    '                        </div>';

            }
            areaMatch += '<li class="flex4 down-area">' + html + '</li>';
        } else if (item.length == 1) {
            var html = '';
            for (var j = 0; j < item.length; j++) {
                var jtem = item[j];
                var teamParam1 = {"team_id": jtem.team_one_data.id};//左侧队伍id
                var teamParam2 = {"team_id": jtem.team_two_data.id};//右侧队伍id
                if (jtem.chang_type == 1) {
                    if (Number(jtem.team_one_data.team_one_fen1) > Number(jtem.team_two_data.team_two_fen1)) {
                        var chang = '<p><em class="win">' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else if (Number(jtem.team_one_data.team_one_fen1) < Number(jtem.team_two_data.team_two_fen1)) {
                        var chang = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else {
                        var chang = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    }
                } else {
                    if (Number(jtem.team_one_data.team_one_fen1) > Number(jtem.team_two_data.team_two_fen1)) {
                        var chang1 = '<p><em class="win">' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else if (Number(jtem.team_one_data.team_one_fen1) < Number(jtem.team_two_data.team_two_fen1)) {
                        var chang1 = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    } else {
                        var chang1 = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                    }
                    if (Number(jtem.team_one_data.team_one_fen2) > Number(jtem.team_two_data.team_two_fen2)) {
                        var chang2 = '<p><em class="win">' + jtem.team_one_data.team_one_fen2 + '</em>:<em>' + jtem.team_two_data.team_two_fen2 + '</em></p>';
                    } else if (Number(jtem.team_one_data.team_one_fen2) < Number(jtem.team_two_data.team_two_fen2)) {
                        var chang2 = '<p><em>' + jtem.team_one_data.team_one_fen2 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen2 + '</em></p>';
                    } else {
                        var chang2 = '<p><em>' + jtem.team_one_data.team_one_fen2 + '</em>:<em>' + jtem.team_two_data.team_two_fen2 + '</em></p>';
                    }
                    var chang = chang1 + chang2;
                }
                html += '<div class="flex-li">' +
                    '                            <div class="flex-match-score">' + chang + '</div>' +
                    '                            <div class="flex-match">' +
                    '                                <div class="flex-match-school" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam1) + ')\'>' +
                    '                                    <h6 class="school-icon  bg-cover"' +
                    '                                        style="background: url(' + ajaxUrl + jtem.team_one_data.icon_path + ')"></h6>' +
                    '                                    <p>' + jtem.team_one_data.title + '</p>' +
                    '                                </div>' +
                    '                                <div class="flex-match-school" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam2) + ')\'>' +
                    '                                    <h6 class="school-icon  bg-cover"' +
                    '                                        style="background: url(' + ajaxUrl + jtem.team_two_data.icon_path + ')"></h6>' +
                    '                                    <p>' + jtem.team_two_data.title + '</p>' +
                    '                                </div>' +
                    '                            </div>' +
                    '                        </div>';

            }
            areaMatch += '<li class="flex2 down-area">' + html + '</li>';
        }
    })

    return areaMatch;

}


//男子总决赛
function getFinalsMatch(item,type,status) {
    var data = '';
    if(status == 1){
        data = item;
    }else {
        data = item.data;
    }
    var html = '';
    $.each(data, function (j, jtem) {

        if(jtem.on_off == 2){
            html += '<div class="flex-li"></div>';
        }else {
            var teamParam1 = {"team_id": jtem.team_one_data.id};//左侧队伍id
            var teamParam2 = {"team_id": jtem.team_two_data.id};//右侧队伍id
            if (jtem.chang_type == 1) {
                if (Number(jtem.team_one_data.team_one_fen1) > Number(jtem.team_two_data.team_two_fen1)) {
                    var chang = '<p><em class="win">' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                } else if (Number(jtem.team_one_data.team_one_fen1) < Number(jtem.team_two_data.team_two_fen1)) {
                    var chang = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                } else {
                    var chang = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                }
            } else {
                if (Number(jtem.team_one_data.team_one_fen1) > Number(jtem.team_two_data.team_two_fen1)) {
                    var chang1 = '<p><em class="win">' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                } else if (Number(jtem.team_one_data.team_one_fen1) < Number(jtem.team_two_data.team_two_fen1)) {
                    var chang1 = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                } else {
                    var chang1 = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                }

                if (Number(jtem.team_one_data.team_one_fen2) > Number(jtem.team_two_data.team_two_fen2)) {
                    var chang2 = '<p><em class="win">' + jtem.team_one_data.team_one_fen2 + '</em>:<em>' + jtem.team_two_data.team_two_fen2 + '</em></p>';
                } else if (Number(jtem.team_one_data.team_one_fen2) < Number(jtem.team_two_data.team_two_fen2)) {
                    var chang2 = '<p><em>' + jtem.team_one_data.team_one_fen2 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen2 + '</em></p>';
                } else {
                    var chang2 = '<p><em>' + jtem.team_one_data.team_one_fen2 + '</em>:<em>' + jtem.team_two_data.team_two_fen2 + '</em></p>';
                }
                var chang = chang1 + chang2;
            }

            if(type == 2){

                html += '<div class="flex-li">' +
                    '                            <div class="flex-match-score">' + chang + '</div>' +
                    '                            <div class="flex-match">' +
                    '                                <div class="flex-match-school" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam1) + ')\'>' +
                    '                                    <h6 class="school-icon  bg-cover"' +
                    '                                        style="background: url(' + ajaxUrl + jtem.team_one_data.icon_path + ')"></h6>' +
                    '                                    <p>' + jtem.team_one_data.title + '</p>' +
                    '                                </div>' +
                    '                                <div class="flex-match-school" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam2) + ')\'>' +
                    '                                    <h6 class="school-icon  bg-cover"' +
                    '                                        style="background: url(' + ajaxUrl + jtem.team_two_data.icon_path + ')"></h6>' +
                    '                                    <p>' + jtem.team_two_data.title + '</p>' +
                    '                                </div>' +
                    '                            </div>' +
                    '                        </div>';
            }else {

                html += '<div class="flex-li">' +
                    '                            <div class="flex-match">' +
                    '                                <div class="flex-match-school" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam1) + ')\'>' +
                    '                                    <h6 class="school-icon  bg-cover"' +
                    '                                        style="background: url(' + ajaxUrl + jtem.team_one_data.icon_path + ')"></h6>' +
                    '                                    <p>' + jtem.team_one_data.title + '</p>' +
                    '                                </div>' +
                    '                                <div class="flex-match-school" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam2) + ')\'>' +
                    '                                    <h6 class="school-icon  bg-cover"' +
                    '                                        style="background: url(' + ajaxUrl + jtem.team_two_data.icon_path + ')"></h6>' +
                    '                                    <p>' + jtem.team_two_data.title + '</p>' +
                    '                                </div>' +
                    '                            </div>' +
                    '                            <div class="flex-match-score">' + chang + '</div>' +
                    '                        </div>';
            }

        }


    })
    return html;

}


//男子总决赛 - 新

function getFinalsMatchItem(item) {
    var jtem = item;
    var html = '';
    if(jtem.on_off == 2){
        html = '<div class="flex-li"></div>';
    }else {
        var teamParam1 = {"team_id": jtem.team_one_data.id};//左侧队伍id
        var teamParam2 = {"team_id": jtem.team_two_data.id};//右侧队伍id
        if (jtem.chang_type == 1) {
            if (Number(jtem.team_one_data.team_one_fen1) > Number(jtem.team_two_data.team_two_fen1)) {
                var chang = '<p><em class="win">' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
            } else if (Number(jtem.team_one_data.team_one_fen1) < Number(jtem.team_two_data.team_two_fen1)) {
                var chang = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen1 + '</em></p>';
            } else {
                var chang = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
            }
        } else {
            if (Number(jtem.team_one_data.team_one_fen1) > Number(jtem.team_two_data.team_two_fen1)) {
                var chang1 = '<p><em class="win">' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
            } else if (Number(jtem.team_one_data.team_one_fen1) < Number(jtem.team_two_data.team_two_fen1)) {
                var chang1 = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen1 + '</em></p>';
            } else {
                var chang1 = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
            }

            if (Number(jtem.team_one_data.team_one_fen2) > Number(jtem.team_two_data.team_two_fen2)) {
                var chang2 = '<p><em class="win">' + jtem.team_one_data.team_one_fen2 + '</em>:<em>' + jtem.team_two_data.team_two_fen2 + '</em></p>';
            } else if (Number(jtem.team_one_data.team_one_fen2) < Number(jtem.team_two_data.team_two_fen2)) {
                var chang2 = '<p><em>' + jtem.team_one_data.team_one_fen2 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen2 + '</em></p>';
            } else {
                var chang2 = '<p><em>' + jtem.team_one_data.team_one_fen2 + '</em>:<em>' + jtem.team_two_data.team_two_fen2 + '</em></p>';
            }
            var chang = chang1 + chang2;
        }

        html = '<div class="flex-li">' +
            '                            <div class="flex-match">' +
            '                                <div class="flex-match-school" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam1) + ')\'>' +
            '                                    <h6 class="school-icon  bg-cover"' +
            '                                        style="background: url(' + ajaxUrl + jtem.team_one_data.icon_path + ')"></h6>' +
            '                                    <p>' + jtem.team_one_data.title + '</p>' +
            '                                </div>' +
            '                                <div class="flex-match-school" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam2) + ')\'>' +
            '                                    <h6 class="school-icon  bg-cover"' +
            '                                        style="background: url(' + ajaxUrl + jtem.team_two_data.icon_path + ')"></h6>' +
            '                                    <p>' + jtem.team_two_data.title + '</p>' +
            '                                </div>' +
            '                            </div>' +
            '                            <div class="flex-match-score">' + chang + '</div>' +
            '                        </div>';

    }
    return html;

}




//男子上下半区决赛
function getFinals(item, type) {

    var html = '';
    $.each(item.data, function (j, jtem) {
        var win1 = '', win2 = '';
        var teamParam1 = {"team_id": jtem.team_one_data.id};//左侧队伍id
        var teamParam2 = {"team_id": jtem.team_two_data.id};//右侧队伍id
        if (jtem.chang_type == 1) {
            if (Number(jtem.team_one_data.team_one_fen1) > Number(jtem.team_two_data.team_two_fen1)) {
                var chang = '<p><em class="win">' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                if (type == 1) {
                    win1 = '<div class="winUp up1"></div>';
                } else {
                    win1 = '<div class="winDown up1"></div>';
                }
            } else if (Number(jtem.team_one_data.team_one_fen1) < Number(jtem.team_two_data.team_two_fen1)) {
                var chang = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen1 + '</em></p>';
                if (type == 1) {
                    win2 = '<div class="winUp up2"></div>';
                } else {
                    win2 = '<div class="winDown up2"></div>';
                }
            } else {
                var chang = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
            }
        } else {
            if (Number(jtem.team_one_data.team_one_fen1) > Number(jtem.team_two_data.team_two_fen1)) {
                var chang1 = '<p><em class="win">' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
            } else if (Number(jtem.team_one_data.team_one_fen1) < Number(jtem.team_two_data.team_two_fen1)) {
                var chang1 = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen1 + '</em></p>';
            } else {
                var chang1 = '<p><em>' + jtem.team_one_data.team_one_fen1 + '</em>:<em>' + jtem.team_two_data.team_two_fen1 + '</em></p>';
            }

            if (Number(jtem.team_one_data.team_one_fen2) > Number(jtem.team_two_data.team_two_fen2)) {
                var chang2 = '<p><em class="win">' + jtem.team_one_data.team_one_fen2 + '</em>:<em>' + jtem.team_two_data.team_two_fen2 + '</em></p>';
            } else if (Number(jtem.team_one_data.team_one_fen2) < Number(jtem.team_two_data.team_two_fen2)) {
                var chang2 = '<p><em>' + jtem.team_one_data.team_one_fen2 + '</em>:<em class="win">' + jtem.team_two_data.team_two_fen2 + '</em></p>';
            } else {
                var chang2 = '<p><em>' + jtem.team_one_data.team_one_fen2 + '</em>:<em>' + jtem.team_two_data.team_two_fen2 + '</em></p>';
            }
            var chang = chang1 + chang2;
        }
        html += '<div class="flex-li">' +
            '                            <div class="flex-match">' +
            '                                <div class="flex-match-school" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam1) + ')\'>' +
            '                                    <h6 class="school-icon  bg-cover"' +
            '                                        style="background: url(' + ajaxUrl + jtem.team_one_data.icon_path + ')"></h6>' +
            '                                    <p>' + jtem.team_one_data.title + '</p>' + win1 +
            '                                </div>' +
            '                                <div class="flex-match-school" tapmode onclick=\'commonUrl("team_detail",' + jsonChange(teamParam2) + ')\'>' +
            '                                    <h6 class="school-icon  bg-cover"' +
            '                                        style="background: url(' + ajaxUrl + jtem.team_two_data.icon_path + ')"></h6>' +
            '                                    <p>' + jtem.team_two_data.title + '</p>' + win2 +
            '                                </div>' +
            '                            </div>' +
            '                            <div class="flex-match-score">' + chang + '</div>' +
            '                        </div>';

    })
    return html;

}

//屏蔽
function shield(id,event,type,that,fn) {
    //type：1新闻，2帖子，3活动，4用户
    event.stopPropagation();
    var param = {
        token: $api.getStorage('token'),
        type: type,
        aid: id,
    }
    var text = '';
    switch(type){
        case 1:
            text = '新闻';
            break;
        case 2:
            text = '帖子';
            break;
        case 3:
            text = '活动';
            break;
        case 4:
            text = '用户';
            break;
    }
    api.confirm({
        title: '提醒',
        msg:'确定要屏蔽该'+text+'吗？',
        buttons:['确定','取消']
    }, function(ret, err) {
        if(ret.buttonIndex == 1){
            getAjax(Interface.add_screen,param,function (res) {
                pop.notice(res.msg);
                if(type != 4){
                    $(that).parents('li').remove();
                }else {
                    fn();
                }
            },function (error) {

            })
        }
    });

}

//移出屏蔽
function cancelShield(aid,type,that,event,status,fn) {
    if(event){
        event.stopPropagation();
    }
    var param ={
        token: $api.getStorage('token'),
        aid: aid,
        type: type,
    }
    getAjax(Interface.del_shield,param,function (res) {

        if(status){
            pop.notice('已解除屏蔽');
            fn();
        }else {
            pop.notice('移出成功');
            $(that).parents('li').remove();
        }
    },function (error) {

    })

}




//举报
function jubao(id,event,type) {
    event.stopPropagation();
    var param = {
        type: type,
        pid: id,
    }
    commonUrl('../member/jubao',param);
}


//帖子
function inviteGetHtml(data) {

    var listHtml = '';

    var listData = data;
    var titleHtml = '';
    var userData = listData.member;
    // console.log(jsonChange(userData))

    var userInfo = '';
    var follow = '';//是否关注
    var badgeList = '';//徽章列表
    var toUp = '';//顶置
    var hotHtml = '';//标签，热度

    //顶置，标签，热度
    if (listData.recommend == 1) {
        toUp = '<span class="bt-pd toUp">置顶</span>';
    }
    var circleP = {"circle_id": listData.circle_id}

    if(listData.self_status == 2){
        if(isDefine(listData.circle_title)){
            hotHtml = '<div class="detail-bottom">' +
                '              <div class="bottom-tips">' + toUp +
                '                   <span class="bt-pd tips" tapmode onclick=\'commonUrl("../circle/circle_index",' + jsonChange(circleP) + ')\'>#' + listData.circle_title + '#</span></div>' +
                '               <div class="line_center" style="justify-content: space-between;">' +
                '                                <div class="shield">' +
                '                                    <span tapmode onclick=\'jubao('+listData.id+',event,3)\'>举报</span>' +
                '                                    <span tapmode onclick=\'shield('+listData.id+',event,2,this)\'>屏蔽</span>' +
                '                                </div>' +
                '                                <div class="bottom-hot">' + listData.hot_number + '</div>' +
                '                            </div>'+
                '          </div>';
        }else {
            hotHtml = '<div class="detail-bottom">' +
                '              <div class="bottom-tips">' + toUp +
                '                   <span class="bt-pd"></span>' +
                '               </div>' +
                '               <div class="line_center" style="justify-content: space-between;">' +
                '                                <div class="shield">' +
                '                                    <span tapmode onclick=\'jubao('+listData.id+',event,3)\'>举报</span>' +
                '                                    <span tapmode onclick=\'shield('+listData.id+',event,2,this)\'>屏蔽</span>' +
                '                                </div>' +
                '                                <div class="bottom-hot">' + listData.hot_number + '</div>' +
                '                            </div>'+
                '          </div>';
        }

    }else {
        if(isDefine(listData.circle_title)){
            hotHtml = '<div class="detail-bottom">' +
                '              <div class="bottom-tips">' + toUp +
                '                   <span class="bt-pd tips" tapmode onclick=\'commonUrl("../circle/circle_index",' + jsonChange(circleP) + ')\'>#' + listData.circle_title + '#</span></div>' +
                '               <div class="bottom-hot">' + listData.hot_number + '</div>'+
                '          </div>';
        }else {
            hotHtml = '<div class="detail-bottom">' +
                '              <div class="bottom-tips">' + toUp +
                '              </div>'+
                '               <div class="bottom-hot">' + listData.hot_number + '</div>'+
                '          </div>';
        }

    }


    if (isDefine(userData.badge_path)) {
        for (var k = 0; k < userData.badge_path.length; k++) {
            if (k <= 5) {
                badgeList += '<dd class="icon"><img src="' + ajaxUrl + userData.badge_path[k] + '" alt=""></dd>'
            }
        }
    }
    var userVip = '';
    if(isDefine(userData.attestation_status)){
        if(userData.attestation_status == 2){
            userVip = '<span class="vip"></span>';
        }
    }

    if(isDefine(listData.self_status)){

        if(listData.self_status == 2){
            var className = 'class'+userData.id;
            if (listData.member_follow == '0') {
                follow = '<div class="follow '+className+'">' +
                    '         <span class="no-follow"  tapmode onclick="followAction(1,' + userData.id + ',this)">关注</span>' +
                    '         <span class="followed"  tapmode onclick="followAction(2,' + userData.id + ',this)">已关注</span>' +
                    '     </div>'
            } else {
                /*follow = '<div class="follow '+className+' on">' +
                    '         <span class="no-follow"  tapmode onclick="followAction(1,' + userData.id + ',this)">关注</span>' +
                    '         <span class="followed"  tapmode onclick="followAction(2,' + userData.id + ',this)">已关注</span>' +
                    '     </div>'*/
            }

            var user = {'member_id': userData.id};
            var report = {type: 5,pid:userData.id}
            var jubao = '<div class="jubao" onclick=\'jubao('+userData.id+',event,5)\'>举报</div>'
            userInfo = '<div class="common-user-detail">' +
                '           <div class="user-info" tapmode onclick=\'commonUrl("../activity/person_index",' + jsonChange(user) + ')\'>' +
                '               <div class="userRelative"><div class="user-icon bg-cover" style="background-image: url(' + ajaxUrl + userData.icon_path + ');"></div>'+userVip+'</div>' +
                '               <div class="info">' +
                '                    <div class="name">' +
                '                        <h6>' + userData.name + '</h6>' +
                '                        <dl class="badge-list" tapmode onclick="toBadgePage(event)">' + badgeList + '</dl>' +
                '                    </div>' +
                '                    <span class="time">' + listData.date + '</span>' +
                '                </div>' +
                '            </div><div class="user-action">' + jubao + follow + '</div></div>';
        }else {

            userInfo = '<div class="common-user-detail">' +
                '           <div class="user-info" tapmode onclick=\'\'>' +
                '               <div class="userRelative"><div class="user-icon bg-cover" style="background-image: url(' + ajaxUrl + userData.icon_path + ');"></div>'+userVip+'</div>' +
                '               <div class="info">' +
                '                    <div class="name">' +
                '                        <h6>' + userData.name + '</h6>' +
                '                        <dl class="badge-list" tapmode onclick="toBadgePage(event)">' + badgeList + '</dl>' +
                '                    </div>' +
                '                    <span class="time">' + listData.date + '</span>' +
                '                </div>' +
                '            </div><div class="user-action">' + follow + '</div></div>';
        }
    }

    var invitation_id = {'invitation_id': listData.id};
    var article = '';
    if (isDefine(listData.title)){
        if (isDefine(listData.content_info)) {
            article = '<div style="word-break: break-all;" class="multiline-ellipsis f26 mb10 c-666">'+listData.content_info+'</div>';
        }
    } else {
        listData.title = listData.content_info;
    }


    if (isDefine(listData.void_path)) {
        //视频帖子
        titleHtml = '<div class="video-detail" tapmode onclick=\'commonUrl("../circle/invite_detail",' + jsonChange(invitation_id) + ')\'>' +
            '             <h6 class="news-title multiline-ellipsis">' + listData.title + '</h6>' + article +
            '             <div class="video-box bg-cover" style="background-image: url(' + ajaxUrl + listData.void_icon_path + ')";>' +
            '                 <p class="single-ellipsis"></p>' +
            '                 <span class="icon-play"></span>' +
            '                 <span class="time"></span>' +
            '              </div>' + hotHtml +
            '         </div>';

    } else {
        if (isDefine(listData.icons_path)) {
            //三张图片帖子
            if (listData.icons_path.length >= 3) {
                titleHtml = '<div class="video-detail" tapmode onclick=\'commonUrl("../circle/invite_detail",' + jsonChange(invitation_id) + ')\'>' +
                    '            <h6 class="news-title multiline-ellipsis">' + listData.title + '</h6>' +article +
                    '            <div class="detail-img-list">' +
                    '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + listData.icons_path[0] + ');"></div>' +
                    '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + listData.icons_path[1] + ');"></div>' +
                    '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + listData.icons_path[2] + ');"></div>' +
                    '            </div>' + hotHtml +
                    '        </div>'
            } else if (listData.icons_path.length == 2) {
                //两张图片帖子
                titleHtml = '<div class="video-detail" tapmode onclick=\'commonUrl("../circle/invite_detail",' + jsonChange(invitation_id) + ')\'>' +
                    '            <h6 class="news-title multiline-ellipsis">' + listData.title + '</h6>' +article +
                    '            <div class="detail-img-list two-img">' +
                    '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + listData.icons_path[0] + ');"></div>' +
                    '                <div class="img bg-cover" style="background-image: url(' + ajaxUrl + listData.icons_path[1] + ');"></div>' +
                    '            </div>' + hotHtml +
                    '        </div>'
            } else if (listData.icons_path.length == 1) {
                //单张图片帖子

                titleHtml = '<div class="video-detail" tapmode onclick=\'commonUrl("../circle/invite_detail",' + jsonChange(invitation_id) + ')\'>' +
                    '              <h6 class="news-title multiline-ellipsis_3">' + listData.title + '</h6>' +article +
                    '              <div class="video-box bg-cover" style="width: 50%;height: 3.5rem; background-image: url(' + ajaxUrl + listData.icons_path[0] + ');"></div>' + hotHtml + '</div>';
            }
        } else {
            //无图
            titleHtml = '<div class="video-detail" tapmode onclick=\'commonUrl("../circle/invite_detail",' + jsonChange(invitation_id) + ')\'>' +
                '            <h6 class="news-title multiline-ellipsis">' + listData.title + '</h6>' + article  + hotHtml +
                '        </div>'
        }


    }

    listHtml += '<li>' + userInfo + titleHtml + '</li>';

    return listHtml;

}

//投票
function voteGetHtml(data) {

    var listHtml = '';

    var listData = data;
    var titleHtml = '';
    var userData = listData.member;
    // console.log(jsonChange(userData))

    var userInfo = '';
    var follow = '';//是否关注
    var badgeList = '';//徽章列表
    var toUp = '';//顶置
    var hotHtml = '';//标签，热度

    //顶置，标签，热度
    if (listData.recommend == 1) {
        toUp = '<span class="bt-pd toUp">置顶</span>';
    }
    var circleP = {"circle_id": listData.circle_id}

    if(listData.self_status == 2){
        if(isDefine(listData.circle_title)){
            hotHtml = '<div class="detail-bottom">' +
                '              <div class="bottom-tips">' + toUp +
                '                   <span class="bt-pd tips" tapmode onclick=\'commonUrl("../circle/circle_index",' + jsonChange(circleP) + ')\'>#' + listData.circle_title + '#</span></div>' +
                '               <div class="line_center" style="justify-content: space-between;">' +
                '                                <div class="shield">' +
                '                                    <span tapmode onclick=\'jubao('+listData.id+',event,3)\'>举报</span>' +
                '                                    <span tapmode onclick=\'shield('+listData.id+',event,2,this)\'>屏蔽</span>' +
                '                                </div>' +
                '                                <div class="bottom-hot">' + listData.hot_number + '</div>' +
                '                            </div>'+
                '          </div>';
        }else {
            hotHtml = '<div class="detail-bottom">' +
                '              <div class="bottom-tips">' + toUp +
                '                   <span class="bt-pd"></span>' +
                '               </div>' +
                '               <div class="line_center" style="justify-content: space-between;">' +
                '                                <div class="shield">' +
                '                                    <span tapmode onclick=\'jubao('+listData.id+',event,3)\'>举报</span>' +
                '                                    <span tapmode onclick=\'shield('+listData.id+',event,2,this)\'>屏蔽</span>' +
                '                                </div>' +
                '                                <div class="bottom-hot">' + listData.hot_number + '</div>' +
                '                            </div>'+
                '          </div>';
        }

    }else {
        if(isDefine(listData.circle_title)){
            hotHtml = '<div class="detail-bottom">' +
                '              <div class="bottom-tips">' + toUp +
                '                   <span class="bt-pd tips" tapmode onclick=\'commonUrl("../circle/circle_index",' + jsonChange(circleP) + ')\'>#' + listData.circle_title + '#</span></div>' +
                '               <div class="bottom-hot">' + listData.hot_number + '</div>'+
                '          </div>';
        }else {
            hotHtml = '<div class="detail-bottom">' +
                '              <div class="bottom-tips">' + toUp +
                '              </div>'+
                '               <div class="bottom-hot">' + listData.hot_number + '</div>'+
                '          </div>';
        }

    }


    if (isDefine(userData.badge_path)) {
        for (var k = 0; k < userData.badge_path.length; k++) {
            if (k <= 5) {
                badgeList += '<dd class="icon"><img src="' + ajaxUrl + userData.badge_path[k] + '" alt=""></dd>'
            }
        }
    }
    var userVip = '';
    if(isDefine(userData.attestation_status)){
        if(userData.attestation_status == 2){
            userVip = '<span class="vip"></span>';
        }
    }

    if(isDefine(listData.self_status)){

        if(listData.self_status == 2){
            var className = 'class'+userData.id;
            if (listData.member_follow == '0') {
                follow = '<div class="follow '+className+'">' +
                    '         <span class="no-follow"  tapmode onclick="followAction(1,' + userData.id + ',this)">关注</span>' +
                    '         <span class="followed"  tapmode onclick="followAction(2,' + userData.id + ',this)">已关注</span>' +
                    '     </div>'
            } else {
                /*follow = '<div class="follow '+className+' on">' +
                    '         <span class="no-follow"  tapmode onclick="followAction(1,' + userData.id + ',this)">关注</span>' +
                    '         <span class="followed"  tapmode onclick="followAction(2,' + userData.id + ',this)">已关注</span>' +
                    '     </div>'*/
            }

            var user = {'member_id': userData.id};
            var report = {type: 5,pid:userData.id}
            var jubao = '<div class="jubao" onclick=\'jubao('+userData.id+',event,5)\'>举报</div>'
            userInfo = '<div class="common-user-detail">' +
                '           <div class="user-info" tapmode onclick=\'commonUrl("../activity/person_index",' + jsonChange(user) + ')\'>' +
                '               <div class="userRelative"><div class="user-icon bg-cover" style="background-image: url(' + ajaxUrl + userData.icon_path + ');"></div>'+userVip+'</div>' +
                '               <div class="info">' +
                '                    <div class="name">' +
                '                        <h6>' + userData.name + '</h6>' +
                '                        <dl class="badge-list" tapmode onclick="toBadgePage(event)">' + badgeList + '</dl>' +
                '                    </div>' +
                '                    <span class="time">' + listData.date + '</span>' +
                '                </div>' +
                '            </div><div class="user-action">' + jubao + follow + '</div></div>';
        }else {

            userInfo = '<div class="common-user-detail">' +
                '           <div class="user-info" tapmode onclick=\'\'>' +
                '               <div class="userRelative"><div class="user-icon bg-cover" style="background-image: url(' + ajaxUrl + userData.icon_path + ');"></div>'+userVip+'</div>' +
                '               <div class="info">' +
                '                    <div class="name">' +
                '                        <h6>' + userData.name + '</h6>' +
                '                        <dl class="badge-list" tapmode onclick="toBadgePage(event)">' + badgeList + '</dl>' +
                '                    </div>' +
                '                    <span class="time">' + listData.date + '</span>' +
                '                </div>' +
                '            </div><div class="user-action">' + follow + '</div></div>';
        }
    }

    var stype = '';//判断单选或者多选，其次 选项是否带图
    var result = '';//投票结果
    var stypeNote = '';//选择说明
    if(listData.status == 1){

        if(listData.member_status == 2){
            var entrylist = '';//条目数
            $.each(listData.entry,function(k,ktem){
                var icon_path = '';
                if(isDefine(ktem.icon_path)){
                    icon_path = '<div class="radio-img bg-cover" style="background: url(' + ajaxUrl + ktem.icon_path + ');"></div>'
                }
                entrylist += '<li data-id="'+ktem.id+'">' + icon_path + '<p class="multiline-ellipsis_3">'+ktem.content+'</p></li>';
            })

            if(listData.stype == 1){
                if(listData.icon_status == 2){
                    stype = '<ul class="choose radioChoose" data-max="'+listData.many_number+'" data-min="'+listData.less_number+'">'+entrylist+'</ul><ul class="voteResult dn"></ul>';
                }else {
                    stype = '<ul class="choose radioChoose imgChoose" data-max="'+listData.many_number+'" data-min="'+listData.less_number+'">'+entrylist+'</ul><ul class="voteResult dn"></ul>';
                }
                stypeNote = '<p>单选</p><p>'+listData.over_time_date+'截止</p>';
            } else {
                if(listData.icon_status == 2){
                    stype = '<ul class="choose checkChoose" data-max="'+listData.many_number+'" data-min="'+listData.less_number+'">'+entrylist+'</ul><ul class="voteResult dn"></ul>';
                }else {
                    stype = '<ul class="choose checkChoose imgChoose" data-max="'+listData.many_number+'" data-min="'+listData.less_number+'">'+entrylist+'</ul><ul class="voteResult dn"></ul>';
                }
                stypeNote = '<p>多选；最多可选'+listData.many_number+'项，最少'+listData.less_number+'项</p><p>'+listData.over_time_date+'截止</p>';
            }
        }else {
            var voteResult = '';//投票结果li
            $.each(listData.entry,function(k,ktem){

                var on = '';
                if(ktem.member_status == 1){
                    on = 'on';
                }
                voteResult += '<li class="'+on+'">'+
                    '    <p class="multiline-ellipsis_3">'+ktem.content+'</p>'+
                    '    <div class="result">'+ktem.number+'票（'+(parseFloat(ktem.entry_rate)*100).toFixed(2)+'%）</div>'+
                    '    <div class="percentage" style="width: '+(parseFloat(ktem.entry_rate)*100).toFixed(2)+'%;"></div>'+
                    '</li>';
            })
            if(listData.stype == 1){
                stypeNote = '<p>单选</p><p>'+listData.over_time_date+'截止</p>';
            } else {
                stypeNote = '<p>多选；最多可选'+listData.many_number+'项，最少'+listData.less_number+'项</p><p>'+listData.over_time_date+'截止</p>';
            }
            result = '<ul class="voteResult">'+voteResult+'</ul>';
        }
    }else {


        var voteResult = '';//投票结果li
        var vote_id = {'vote_id': listData.id,"type": 2};
        $.each(listData.entry,function(k,ktem){

            var on = '';
            if(ktem.member_status == 1){
                on = 'on';
            }
            voteResult += '<li class="'+on+'">'+
                '    <p class="multiline-ellipsis_3">'+ktem.content+'</p>'+
                '    <div class="result">'+ktem.number+'票（'+(parseFloat(ktem.entry_rate)*100).toFixed(2)+'%）</div>'+
                '    <div class="percentage" style="width: '+(parseFloat(ktem.entry_rate)*100).toFixed(2)+'%;"></div>'+
                '</li>';
        })
        if(listData.stype == 1){
            stypeNote = '<p>单选</p><p>'+listData.over_time_date+'截止</p>';
        } else {
            stypeNote = '<p>多选；最多可选'+listData.many_number+'项，最少'+listData.less_number+'项</p><p>'+listData.over_time_date+'截止</p>';
        }
        result = '<ul class="voteResult">'+voteResult+'</ul>';
    }




    var voteBtn = '';//是否为本人，是否已投票，本人为1；
    var vote_id = {'vote_id': listData.id,"type": 2};

    if(listData.self_status == 1){
        if(listData.member_status == 2){
            if(listData.status == 1){
                voteBtn = '<a href="javascript:void(0);" tapmode onclick=\'commonUrl("../circle/vote_result",' + jsonChange(vote_id) + ')\' class="look-btn btn">查看结果</a>' +
                    '<a href="javascript:void(0);" class="vote-btn btn" tapmode onclick="actionVote(2,'+listData.id+',this)">投票</a>';
            }else {
                voteBtn = '<a href="javascript:void(0);" tapmode onclick=\'commonUrl("../circle/vote_result",' + jsonChange(vote_id) + ')\' class="look-btn btn">查看结果</a>' +
                    '<a href="javascript:void(0);" class="voted-btn btn">已结束</a>';
            }

        }else {
            voteBtn = '<a href="javascript:void(0);" tapmode onclick=\'commonUrl("../circle/vote_result",' + jsonChange(vote_id) + ')\' class="look-btn btn">查看结果</a>' +
                '<a href="javascript:void(0);" class="voted-btn btn">已投票</a>';
        }
    }else {
        if(listData.member_status == 2){
            if(listData.status == 1){
                voteBtn = '<a href="javascript:void(0);" class="vote-btn btn" tapmode onclick="actionVote(2,'+listData.id+',this)">投票</a>';
            }else {
                voteBtn = '<a href="javascript:void(0);" class="voted-btn btn">已结束</a>';
            }

        }else {
            voteBtn = '<a href="javascript:void(0);" class="voted-btn btn">已投票</a>';
        }
    }

    var voteStatus = '';//投票是否截止
    if(listData.status == 1){
        voteStatus = '<span class="status being">进行中</span>';
    }else {
        voteStatus = '<span class="status end">已结束</span>';
    }

    var votePic = '';//投票图
    if(isDefine(listData.icon_path)){
        votePic = '<div class="votePic bg-cover" style="width: 100%;height: 3.5rem; border-radius: 0.1rem; background: url('+ajaxUrl + listData.icon_path+')" tapmode onclick=\'commonUrl("../circle/vote_detail",' + jsonChange(vote_id) + ')\'>' +
            // '              <img src="'+ajaxUrl + listData.icon_path+'" alt="">' +
            '          </div>';
    }

    titleHtml = '<div class="video-detail">' +
        '            <h6 tapmode onclick=\'commonUrl("../circle/vote_detail",' + jsonChange(vote_id) + ')\' class="news-title multiline-ellipsis_3">' + voteStatus + listData.title +
        '</h6>' + votePic + '<div class="voteView">' + stype + result + '<div class="vote-note">' + stypeNote + '</div>' +
        '              <div class="vote-action">' + voteBtn + '</div>' +
        '           </div>' + hotHtml +
        '         </div>';

    listHtml += '<li>' + userInfo + titleHtml + '</li>';


    return listHtml;

}


//投票详情 - 模板
function vote_detail(listData,type){
    //type 1为新闻，2为投票贴
    var listHtml = '';
    var stype = '';//判断单选或者多选，其次 选项是否带图
    var result = '';//投票结果
    var stypeNote = '';//选择说明
    if(listData.status == 1){

        if(listData.member_status == 2){
            var entrylist = '';//条目数
            $.each(listData.entry,function(k,ktem){
                var icon_path = '';
                if(isDefine(ktem.icon_path)){
                    icon_path = '<div class="radio-img bg-cover" style="background: url(' + ajaxUrl + ktem.icon_path + ');"></div>'
                }
                entrylist += '<li data-id="'+ktem.id+'">' + icon_path + '<p class="multiline-ellipsis_3">'+ktem.content+'</p></li>';
            })

            if(listData.stype == 1){
                if(listData.icon_status == 2){
                    stype = '<ul class="choose radioChoose" data-max="'+listData.many_number+'" data-min="'+listData.less_number+'">'+entrylist+'</ul><ul class="voteResult dn"></ul>';
                }else {
                    stype = '<ul class="choose radioChoose imgChoose" data-max="'+listData.many_number+'" data-min="'+listData.less_number+'">'+entrylist+'</ul><ul class="voteResult dn"></ul>';
                }
                stypeNote = '<p>单选</p><p>'+listData.over_time_date+'截止</p>';
            } else {
                if(listData.icon_status == 2){
                    stype = '<ul class="choose checkChoose" data-max="'+listData.many_number+'" data-min="'+listData.less_number+'">'+entrylist+'</ul><ul class="voteResult dn"></ul>';
                }else {
                    stype = '<ul class="choose checkChoose imgChoose" data-max="'+listData.many_number+'" data-min="'+listData.less_number+'">'+entrylist+'</ul><ul class="voteResult dn"></ul>';
                }
                stypeNote = '<p>多选；最多可选'+listData.many_number+'项，最少'+listData.less_number+'项</p><p>'+listData.over_time_date+'截止</p>';
            }
        }else {
            var voteResult = '';//投票结果li
            $.each(listData.entry,function(k,ktem){

                var on = '';
                if(ktem.member_status == 1){
                    on = 'on';
                }
                voteResult += '<li class="'+on+'">'+
                    '    <p class="multiline-ellipsis_3">'+ktem.content+'</p>'+
                    '    <div class="result">'+ktem.number+'票（'+(parseFloat(ktem.entry_rate)*100).toFixed(2)+'%）</div>'+
                    '    <div class="percentage" style="width: '+(parseFloat(ktem.entry_rate)*100).toFixed(2)+'%;"></div>'+
                    '</li>';
            })
            if(listData.stype == 1){
                stypeNote = '<p>单选</p><p>'+listData.over_time_date+'截止</p>';
            } else {
                stypeNote = '<p>多选；最多可选'+listData.many_number+'项，最少'+listData.less_number+'项</p><p>'+listData.over_time_date+'截止</p>';
            }
            result = '<ul class="voteResult">'+voteResult+'</ul>';
        }
    }else {


        var voteResult = '';//投票结果li
        $.each(listData.entry,function(k,ktem){

            var on = '';
            if(ktem.member_status == 1){
                on = 'on';
            }
            voteResult += '<li class="'+on+'">'+
                '    <p class="multiline-ellipsis_3">'+ktem.content+'</p>'+
                '    <div class="result">'+ktem.number+'票（'+(parseFloat(ktem.entry_rate)*100).toFixed(2)+'%）</div>'+
                '    <div class="percentage" style="width: '+(parseFloat(ktem.entry_rate)*100).toFixed(2)+'%;"></div>'+
                '</li>';
        })
        if(listData.stype == 1){
            stypeNote = '<p>单选</p><p>'+listData.over_time_date+'截止</p>';
        } else {
            stypeNote = '<p>多选；最多可选'+listData.many_number+'项，最少'+listData.less_number+'项</p><p>'+listData.over_time_date+'截止</p>';
        }
        result = '<ul class="voteResult">'+voteResult+'</ul>';
    }





    var voteBtn = '';//是否为本人，是否已投票，本人为1；
    var vote_id = {'vote_id': listData.id,"type": type};

    if(listData.self_status == 1){
        if(listData.member_status == 2){
            var tpNum = 2;
            if(type == 1){
                tpNum = 1
            }
            if(listData.status == 1){
                voteBtn = '<div tapmode onclick=\'commonUrl("../circle/vote_result",' + jsonChange(vote_id) + ')\' class="look-btn btn">查看结果</div>' +
                    '<div class="vote-btn btn" tapmode onclick="actionVote('+tpNum+','+listData.id+',this)">投票</div>';
            }else {
                voteBtn = '<div tapmode onclick=\'commonUrl("../circle/vote_result",' + jsonChange(vote_id) + ')\' class="look-btn btn">查看结果</div>' +
                    '<div class="voted-btn btn"">已结束</a>';
            }

        }else {
            voteBtn = '<div tapmode onclick=\'commonUrl("../circle/vote_result",' + jsonChange(vote_id) + ')\' class="look-btn btn">查看结果</div>' +
                '<div class="voted-btn btn">已投票</div>';
        }
    }else {
        if(listData.member_status == 2){
            var tpNum = 2;
            if(type == 1){
                tpNum = 1
            }
            if(listData.status == 1){
                voteBtn = '<div class="vote-btn btn" tapmode onclick="actionVote('+tpNum+','+listData.id+',this)">投票</div>';
            }else {
                voteBtn = '<div class="voted-btn btn">已结束</div>';
            }

        } else {
            voteBtn = '<div class="voted-btn btn">已投票</div>';
        }
    }

    var voteStatus = '';//投票是否截止
    if(listData.status == 1){
        voteStatus = '<span class="status being">进行中</span>';
    }else {
        voteStatus = '<span class="status end">已结束</span>';
    }

    var votePic = '';//投票图
    if(isDefine(listData.icon_path)){
        votePic = '<div class="votePic" style="width: 100%;">' +
            '              <img src="'+ajaxUrl + listData.icon_path+'" alt="">' +
            '          </div>';
    }

    var titleHtml = '<div class="video-detail">' +
        '            <h6 tapmode class="news-title multiline-ellipsis_3">' + voteStatus + listData.title +
        '</h6>' + votePic + '<div class="voteView">' + stype + result + '<div class="vote-note">' + stypeNote + '</div>' +
        '              <div class="vote-action">' + voteBtn + '</div>' +
        '           </div>' +
        '         </div>';

    listHtml = '<li style="padding-top: 0;">' + titleHtml + '</li>';


    return listHtml;
}


//会员投票
function setVote(type,id,entry,fun){

    var param = {
        token: $api.getStorage('token'),
        type: type,
        vote_id: id,
        entry: entry
    }
    pop.loading();
    getAjax(Interface.set_vote, param, function (res) {
        fun(res)
        pop.close();
        pop.notice(res.msg);
    },function(error){
        pop.close();
        pop.notice(error.msg);
    })
}

//投票功能 - 单选
$(".index-news").on('click',".radioChoose li",function(){
    var _this = $(this);
    _this.addClass('on').siblings('li').removeClass('on');
    var _id = _this.attr('data-id');
    _this.parents('.radioChoose').siblings('.vote-action').find('.vote-btn').attr('data-id',_id);
})


//投票功能 - 多选
$(".index-news").on('click',".checkChoose li",function(){
    var _this = $(this);
    var _this_id = _this.attr('data-id');
    var _thisP = _this.parents('.checkChoose');
    var _max = _thisP.attr('data-max');
    var _min = _thisP.attr('data-min');
    var _num = _thisP.find('.on').length;
    var vote = _this.parents('.choose').siblings('.vote-action').find('.vote-btn').attr('data-id');
    if(_this.hasClass('on')){
        if(_num >= _min){
            _this.removeClass('on');
            vote = vote.split(',');
            vote.splice($.inArray(_this_id, vote), 1).join(',');
            _this.parents('.choose').siblings('.vote-action').find('.vote-btn').attr('data-id',vote)
        }else {
            pop.notice('最少选择'+_min+'项')
        }
        _this.removeClass('on');
    }else {
        if(_num < _max){
            _this.addClass('on');
            if(_num == 0){
                vote = _this_id;
            }else {
                vote += ',' + _this_id;
            }
            _this.parents('.choose').siblings('.vote-action').find('.vote-btn').attr('data-id',vote)
        }else {
            pop.notice('最多选择'+_max+'项')
        }
    }
    console.log(_num)
})

function actionVote(type,id,that) {
    var entry = $(that).attr('data-id');
    if(!entry){
        pop.notice('请选择选项，再进行投票')
        return;
    }
    console.log(entry);
    setVote(type,id,entry,function(res){
        // console.log(jsonChange(res));
        var data = res.data;
        var voteResult = '';//投票结果li
        $.each(data.entry,function(k,ktem){
            var on = '';
            if(ktem.member_status == 1){
                on = 'on';
            }
            voteResult += '<li class="'+on+'">'+
                '    <p class="multiline-ellipsis_3">'+ktem.content+'</p>'+
                '    <div class="result">'+ktem.number+'票（'+(parseFloat(ktem.entry_rate)*100).toFixed(2)+'%）</div>'+
                '    <div class="percentage" style="width: '+(parseFloat(ktem.entry_rate)*100).toFixed(2)+'%;"></div>'+
                '</li>';
        })
        $(that).removeClass('vote-btn').addClass('voted-btn').html('已投票');
        $(that).removeAttr("onclick");
        $(that).parents(".vote-action").siblings(".choose").hide();
        $(that).parents(".vote-action").siblings(".voteResult").show().html(voteResult);

    },function (error) {
        pop.notice(error.msg);
    })
}


//新闻数据
function getNewsText(data,leixing,category_id,type){
    var listHtml = '';
    //是否置顶
    var toUp = '';
    var hotHtml = '';

    if (isDefine(data)) {
        if(category_id != 47){
            if (data.recommend == 1) {
                toUp = '<span class="bt-pd toUp">置顶</span>';
            }
        }

        var shield = '<div class="line_center" style="justify-content: space-between;">' +
            '                                <div class="shield">' +
            '                                    <span tapmode onclick=\'jubao(' + data.id + ',event,1)\'>举报</span>' +
            '                                    <span tapmode onclick=\'shield(' + data.id + ',event,1,this)\'>屏蔽</span>' +
            '                                </div>' +
            '                                <div class="bottom-hot">' + data.hot_number + '</div>' +
            '                            </div>';

        var news_label = '';
        if (isDefine(data.news_label_name)) {
            $.each(data.news_label_name,function (k,ktem) {
                if(k<2){
                    news_label += '<span class="bt-pd tips" onclick=\'commonUrl("../index/news_list",{tips_id:' + ktem.id + '})\'>#' + ktem.title + '#</span>'
                }
            });
        }
        hotHtml = '<div class="detail-bottom">' +
            '              <div class="bottom-tips">' + toUp + news_label +
            // '                  <span class="bt-pd time">' + data.date + '</span>' +
            '              </div>' + shield +
            '          </div>';


    }
    var param;
    var url;
    if(isDefine(data.url)){
        param = {"url": data.url,"news_id": data.id};
        url = '../index/banner_detail';
    }else {
        param = {"news_id": data.id};
        url = "../index/news_detail";
    }

    var titleHtml = '';

    var voteStatus = '';//投票是否截止
    if(data.svote_status == 1){
        voteStatus = '<span class="status being">进行中</span>';
    }else if(data.svote_status == 2){
        voteStatus = '<span class="status end">已结束</span>';
    }
    var hover = '';//是否已浏览该新闻
    if(isDefine(data.look_status)){
        if(data.look_status == 1){
            hover = 'hover';
        }
    }
    if (isDefine(data.void_ids) && data.void_ids != 0) {
        // var video_path = getVideoPic(ajaxUrl + list[i].data.void_ids);
        var video_path = '';
        if (leixing == 4 && data.void_ids)  {
            param = {"war_id": data.id}
            url = "../match/match_detail";
        }
        var lazy = '';
        if(type == 1){
            lazy = '<div class="video-box bg-cover" style="background: url('+ajaxUrl + data.void_icon_path+')" tapmode onclick=\'commonUrl("' + url + '",' + jsonChange(param) + ',this)\'>';
        }else {
            lazy = '<div class="video-box bg-cover" imgurl="'+ajaxUrl + data.void_icon_path+'" tapmode onclick=\'commonUrl("' + url + '",' + jsonChange(param) + ',this)\'>';
        }
        titleHtml = '<div class="video-detail '+hover+'" tapmode onclick="addClassHover(this)">' +
            '             <h6 class="news-title  multiline-ellipsis" tapmode onclick=\'commonUrl("' + url + '",' + jsonChange(param) + ',this)\'>' + voteStatus + data.title + '</h6>' + lazy+
            '                 <p class="single-ellipsis"></p>' +
            '                 <span class="icon-play"></span>' +
            '                 <span class="time"></span>' +
            '              </div>' + hotHtml +
            '         </div>';



    } else {
        if (leixing == 4)  {
            param = {"war_id": data.id}
            url = "../match/match_detail2";
        }
        //三张图片新闻
        if (isDefine(data.icon_path)) {
            if (data.icon_path.length >= 3) {
                var lazy = '';
                if(type == 1){
                    lazy = '<div class="img bg-cover" style="background: url('+ajaxUrl + data.icon_path[0]+')"></div>' +
                        '<div class="img bg-cover" style="background: url('+ajaxUrl + data.icon_path[1]+')"></div>' +
                        '<div class="img bg-cover" style="background: url('+ajaxUrl + data.icon_path[2]+')"></div>';
                }else {
                    lazy = '<div class="img bg-cover" imgurl="'+ajaxUrl + data.icon_path[0]+'"></div>' +
                        '<div class="img bg-cover" imgurl="'+ajaxUrl + data.icon_path[1]+'"></div>' +
                        '<div class="img bg-cover" imgurl="'+ajaxUrl + data.icon_path[2]+'"></div>';
                }
                titleHtml = '<div class="video-detail '+hover+'" tapmode onclick="addClassHover(this)">' +
                    '            <h6 class="news-title multiline-ellipsis" tapmode onclick=\'commonUrl("' + url + '",' + jsonChange(param) + ',this)\'>' + voteStatus +  data.title + '</h6>' +
                    '            <div class="detail-img-list" tapmode onclick=\'commonUrl("' + url + '",' + jsonChange(param) + ',this)\'>' +lazy +'</div>' + hotHtml +
                    '        </div>'
            } else if (data.icon_path.length == 2) {
                //两张图片新闻
                var lazy = '';
                if(type == 1){
                    lazy = '<div class="img bg-cover" style="background: url('+ajaxUrl + data.icon_path[0]+')"></div>' +
                        '<div class="img bg-cover" style="background: url('+ajaxUrl + data.icon_path[1]+')"></div>';
                }else {
                    lazy = '<div class="img bg-cover" imgurl="'+ajaxUrl + data.icon_path[0]+'"></div>' +
                        '<div class="img bg-cover" imgurl="'+ajaxUrl + data.icon_path[1]+'"></div>';
                }
                titleHtml = '<div class="video-detail '+hover+'" tapmode onclick="addClassHover(this)">' +
                    '            <h6 class="news-title multiline-ellipsis" tapmode onclick=\'commonUrl("' + url + '",' + jsonChange(param) + ',this)\'>' + voteStatus +  data.title + '</h6>' +
                    '            <div class="detail-img-list two-img" tapmode onclick=\'commonUrl("' + url + '",' + jsonChange(param) + ',this)\'>' + lazy + '</div>' + hotHtml +
                    '        </div>';
            } else if (data.icon_path.length == 1) {

                //单张图片新闻

                shield = '<div class="line_center" style="justify-content: space-between;">' +
                    '                                <div class="shield">' +
                    '                                    <span tapmode onclick=\'jubao(' + data.id + ',event,1)\'>举报</span>' +
                    '                                    <span tapmode onclick=\'shield(' + data.id + ',event,1,this)\'>屏蔽</span>' +
                    '                                </div>' +
                    '                                <div class="bottom-hot">' + data.hot_number + '</div>' +
                    '                            </div>';

                news_label = '';
                if (isDefine(data.news_label_name)) {
                    $.each(data.news_label_name,function (k, ktem) {
                        if(k<2){
                            news_label += '<span class="bt-pd tips" onclick=\'commonUrl("../index/news_list",{tips_id:' + ktem.id + '})\'>#' + ktem.title + '#</span>';
                        }
                    });
                }
                hotHtml = '<div class="detail-bottom">' +
                    '              <div class="bottom-tips">' + toUp + news_label + '</div>' + shield +
                    '          </div>';

                var lazy = '';
                if(type == 1){
                    lazy = '<div class="img bg-cover"  style="background: url('+ajaxUrl + data.icon_path[0]+')" ></div>';
                }else {
                    lazy = '<div class="img bg-cover" imgurl="'+ajaxUrl + data.icon_path[0]+'" ></div>';
                }

                titleHtml = '<div class="single-news">' +
                    '             <div class="detail-img-list" tapmode onclick=\'commonUrl("' + url + '",' + jsonChange(param) + ')\'>' + lazy +'</div>' +
                    '             <div class="video-detail '+hover+'" tapmode onclick="addClassHover(this)">' +
                    '                 <h6 class="news-title multiline-ellipsis_3" tapmode onclick=\'commonUrl("' + url + '",' + jsonChange(param) + ',this)\'>' + voteStatus +  data.title + '</h6>' + hotHtml +
                    /* '                 <p class="detail-info multiline-ellipsis" tapmode onclick=\'commonUrl("'+url+'",' + jsonChange(param) + ')\'>' + list[i].data.brief + '</p>' + hotHtml +*/
                    '             </div>' +
                    '         </div>';



            }

        }else {
            //无图
            titleHtml = '<div class="video-detail '+hover+'" tapmode onclick="addClassHover(this)" >' +
                '            <h6 class="news-title multiline-ellipsis" tapmode onclick=\'commonUrl("' + url + '",' + jsonChange(param) + ',this)\'>' + voteStatus +  data.title + '</h6>' + hotHtml +
                '        </div>';
        }

    }

    listHtml += '<div class="index-news"><ul><li>' + titleHtml + '</li></ul></div>'


    return listHtml;

}

function addClassHover(that) {

    var _this = $(that);
    _this.addClass('hover');

}

//帖子数据
function getInviteText(data,type){
    //type 为1是圈子详情
    var listHtml = '';
    var listData = data;
    if (isDefine(listData)) {
        var titleHtml = '';
        var userData = listData.member;
        console.log(jsonChange(userData))

        var userInfo = '';
        var follow = '';//是否关注
        var badgeList = '';//徽章列表
        var toUp = '';//顶置
        var hotHtml = '';//标签，热度

        //顶置，标签，热度
        if (listData.top == 1) {
            toUp = '<span class="bt-pd toUp">置顶</span>';
        }
        var circleP = {"circle_id": listData.circle_id}

        if(isDefine(type)){
            if(type == 1){

                var qjt = '';//请教帖
                if(listData.type == 2){
                    qjt = '<span class="bt-pd tips">#请教帖#</span>'
                }
                var shield = '';
                if (listData.self_status == 2) {
                    shield = '<div class="line_center" style="justify-content: space-between;">' +
                        '       <div class="shield">' +
                        '          <span tapmode onclick=\'jubao(' + listData.id + ',event,3)\'>举报</span>' +
                        '          <span tapmode onclick=\'shield(' + listData.id + ',event,2,this)\'>屏蔽</span>' +
                        '       </div>' +
                        '       <div class="bottom-hot">' + listData.hot_number + '</div>' +
                        '     </div>';

                } else {
                    shield = '<div class="bottom-hot">' + listData.hot_number + '</div>';
                }

                hotHtml = '<div class="detail-bottom">' +
                    '              <div class="bottom-tips">' + toUp + qjt +
                    '              </div>' + shield +
                    '      </div>';
            }
        }else {
            var shield = '';
            if (listData.self_status == 2) {
                shield = '<div class="line_center" style="justify-content: space-between;">' +
                    '       <div class="shield">' +
                    '          <span tapmode onclick=\'jubao(' + listData.id + ',event,3)\'>举报</span>' +
                    '          <span tapmode onclick=\'shield(' + listData.id + ',event,2,this)\'>屏蔽</span>' +
                    '       </div>' +
                    '       <div class="bottom-hot">' + listData.hot_number + '</div>' +
                    '     </div>';

            } else {
                shield = '<div class="bottom-hot">' + listData.hot_number + '</div>';
            }

            var　circle_title = '';
            if(isDefine(listData.circle_title)){
                circle_title = '<span class="bt-pd tips" tapmode onclick=\'commonUrl("../circle/circle_index",' + jsonChange(circleP) + ')\'>#' + listData.circle_title + '#</span></div>'
            }
            hotHtml = '<div class="detail-bottom">' +
                '              <div class="bottom-tips">' + toUp + circle_title + shield +
                '              </div>'+
                '       </div>';

        }



        if (isDefine(userData.badge_path)) {
            for (var k = 0; k < userData.badge_path.length; k++) {
                if (k <= 5) {
                    badgeList += '<dd class="icon"><img src="' + ajaxUrl + userData.badge_path[k] + '" alt=""></dd>'
                }
            }
        }
        var userVip = '';
        if(isDefine(userData.attestation_status)){
            if(userData.attestation_status == 2){
                userVip = '<span class="vip"></span>';
            }
        }

        if (isDefine(listData.self_status)) {

            if (listData.self_status == 2) {
                var className = 'class' + userData.id;
                if (listData.member_follow == '0') {
                    follow = '<div class="follow ' + className + '">' +
                        '         <span class="no-follow"  tapmode onclick="followAction(1,' + userData.id + ',this)">关注</span>' +
                        '         <span class="followed"  tapmode onclick="followAction(2,' + userData.id + ',this)">已关注</span>' +
                        '     </div>'
                } else {
                    /*follow = '<div class="follow ' + className + ' on">' +
                        '         <span class="no-follow"  tapmode onclick="followAction(1,' + userData.id + ',this)">关注</span>' +
                        '         <span class="followed"  tapmode onclick="followAction(2,' + userData.id + ',this)">已关注</span>' +
                        '     </div>'*/
                }

                var user = {'member_id': userData.id};
                var report = {type: 5, pid: userData.id}
                var jubao = '<div class="jubao" onclick=\'jubao('+userData.id+',event,5)\'>举报</div>'
                userInfo = '<div class="common-user-detail">' +
                    '           <div class="user-info" tapmode onclick=\'commonUrl("../activity/person_index",' + jsonChange(user) + ')\'>' +
                    '               <div class="userRelative"><div class="user-icon bg-cover" style="background-image: url(' + ajaxUrl + userData.icon_path + ');"></div>'+userVip+'</div>' +
                    '               <div class="info">' +
                    '                    <div class="name">' +
                    '                        <h6>' + userData.name + '</h6>' +
                    '                        <dl class="badge-list" tapmode onclick="toBadgePage(event)">' + badgeList + '</dl>' +
                    '                    </div>' +
                    '                    <span class="time">' + listData.date + '</span>' +
                    '                </div>' +
                    '            </div><div class="user-action">' + jubao + follow + '</div></div>';
            } else {

                userInfo = '<div class="common-user-detail">' +
                    '           <div class="user-info" tapmode onclick=\'commonUrl("../member/member")\'>' +
                    '               <div class="userRelative"><div class="user-icon bg-cover" style="background-image: url(' + ajaxUrl + userData.icon_path + ');"></div>'+userVip+'</div>' +
                    '               <div class="info">' +
                    '                    <div class="name">' +
                    '                        <h6>' + userData.name + '</h6>' +
                    '                        <dl class="badge-list" tapmode onclick="toBadgePage(event)">' + badgeList + '</dl>' +
                    '                    </div>' +
                    '                    <span class="time">' + listData.date + '</span>' +
                    '                </div>' +
                    '            </div><div class="user-action">' + follow + '</div></div>';
            }
        }

        var invitation_id = {'invitation_id': listData.id};

        var article = '';
        if (isDefine(listData.title)){
            if (isDefine(listData.content_info)) {
                article = '<div style="word-break: break-all;" class="multiline-ellipsis f26 mb10 c-666">'+listData.content_info+'</div>';
            }
        } else {
            listData.title = listData.content_info;
        }

        if (isDefine(listData.void_path)) {
            var lazy = '';
            if(type == 1){
                lazy = '<div class="video-box bg-cover" style="background-image: url('+ajaxUrl + listData.void_icon_path+')">';
            }else {
                lazy = '<div class="video-box bg-cover" imgurl="'+ajaxUrl + listData.void_icon_path+'">';
            }
            //视频帖子
            titleHtml = '<div class="video-detail" tapmode onclick=\'commonUrl("../circle/invite_detail",' + jsonChange(invitation_id) + ')\'>' +
                '             <h6 class="news-title multiline-ellipsis">' + listData.title + '</h6>' + article + lazy +
                '                 <p class="single-ellipsis"></p>' +
                '                 <span class="icon-play"></span>' +
                '                 <span class="time"></span>' +
                '              </div>' + hotHtml +
                '         </div>';

        } else {
            if (isDefine(listData.icons_path)) {
                //三张图片帖子
                if (listData.icons_path.length >= 3) {
                    var lazy = '';
                    if(type == 1){
                        lazy = '<div class="img bg-cover" style="background-image: url('+ajaxUrl + listData.icons_path[0]+')"></div>' +
                            '<div class="img bg-cover" style="background-image: url('+ajaxUrl + listData.icons_path[1]+')"></div>' +
                            '<div class="img bg-cover" style="background-image: url('+ajaxUrl + listData.icons_path[2]+')"></div>';
                    }else {
                        lazy = '<div class="img bg-cover" imgurl="'+ajaxUrl + listData.icons_path[0]+'"></div>' +
                            '<div class="img bg-cover" imgurl="'+ajaxUrl + listData.icons_path[1]+'"></div>' +
                            '<div class="img bg-cover" imgurl="'+ajaxUrl + listData.icons_path[2]+'"></div>';
                    }
                    titleHtml = '<div class="video-detail" tapmode onclick=\'commonUrl("../circle/invite_detail",' + jsonChange(invitation_id) + ')\'>' +
                        '            <h6 class="news-title multiline-ellipsis">' + listData.title + '</h6>' + article +
                        '            <div class="detail-img-list">' + lazy +'</div>' + hotHtml +
                        '        </div>'
                } else if (listData.icons_path.length == 2) {
                    //两张图片帖子
                    var lazy = '';
                    if(type == 1){
                        lazy = '<div class="img bg-cover" style="background-image: url('+ajaxUrl + listData.icons_path[0]+')"></div>' +
                            '<div class="img bg-cover" style="background-image: url('+ajaxUrl + listData.icons_path[1]+')"></div>';
                    }else {
                        lazy = '<div class="img bg-cover" imgurl="'+ajaxUrl + listData.icons_path[0]+'"></div>' +
                            '<div class="img bg-cover" imgurl="'+ajaxUrl + listData.icons_path[1]+'"></div>';
                    }
                    titleHtml = '<div class="video-detail" tapmode onclick=\'commonUrl("../circle/invite_detail",' + jsonChange(invitation_id) + ')\'>' +
                        '            <h6 class="news-title multiline-ellipsis">' + listData.title + '</h6>' + article +
                        '            <div class="detail-img-list two-img">' + lazy + '</div>' + hotHtml +
                        '        </div>'
                } else if (listData.icons_path.length == 1) {
                    var lazy = '';
                    if(type == 1){
                        lazy = '<div class="video-box bg-cover" style="width: 50%;height: 3.5rem; background-image: url('+ajaxUrl + listData.icons_path[0]+')"></div>';
                        console.log(lazy)
                    }else {
                        lazy = '<div class="video-box bg-cover" style="width: 50%;height: 3.5rem;" imgurl="'+ajaxUrl + listData.icons_path[0]+'"></div>';
                    }
                    //单张图片帖子
                    titleHtml = '<div class="video-detail" tapmode onclick=\'commonUrl("../circle/invite_detail",' + jsonChange(invitation_id) + ')\'>' +
                        '              <h6 class="news-title multiline-ellipsis_3">' + listData.title + '</h6>' + article + lazy + hotHtml + '</div>';
                }
            } else {
                //无图
                titleHtml = '<div class="video-detail" tapmode onclick=\'commonUrl("../circle/invite_detail",' + jsonChange(invitation_id) + ')\'>' +
                    '            <h6 class="news-title multiline-ellipsis">' + listData.title + '</h6>' + article + hotHtml +
                    '        </div>'
            }


        }

    }

    if(isDefine(type)){
        if(type == 1){
            listHtml += '<li>' + userInfo + titleHtml + '</li>';
        }
    }else {
        listHtml += '<div class="index-news user-dynamic"><ul><li>' + userInfo + titleHtml + '</li></ul></div>';

    }

    return listHtml;

}

//活动数据
function getActivityText(data,type) {
    //type 1为圈子里面的
    var listHtml = '';
    var listData = data;
    if (isDefine(listData)) {
        var userInfo = '';
        var userData = listData.member;
        var follow = '';//是否关注
        var badgeList = '';//徽章列表
        // console.log(jsonChange(listData))

        var hotHtml = '';//标签，热度
        var toUp = '';

        //顶置，标签，热度
        if (listData.recommend == 1) {
            toUp = '<span class="bt-pd toUp">置顶</span>';
        }
        var circleP = {"circle_id": listData.circle_id}

        if(isDefine(type)){
            if(type == 1){
                var tips = '';//标签
                if (isDefine(listData.cut_list)) {
                    for (var z = 0; z < listData.cut_list.length; z++) {
                        tips += '<span class="bt-pd tips">#' + listData.cut_list[z] + '#</span>'
                    }
                }
                var shield = '';
                if (listData.self_status == 2) {
                    shield = '<div class="line_center" style="justify-content: space-between;">' +
                        '       <div class="shield">' +
                        '          <span tapmode onclick=\'jubao(' + listData.id + ',event,3)\'>举报</span>' +
                        '          <span tapmode onclick=\'shield(' + listData.id + ',event,2,this)\'>屏蔽</span>' +
                        '       </div>' +
                        '       <div class="bottom-hot">' + listData.hot_number + '</div>' +
                        '     </div>';

                } else {
                    shield = '<div class="bottom-hot">' + listData.hot_number + '</div>';
                }

                hotHtml = '<div class="detail-bottom">' +
                    '              <div class="bottom-tips">' + toUp + tips +
                    '              </div>' + shield +
                    '      </div>';
            }
        }else {
            var shield = '';
            if (listData.self_status == 2) {
                shield = '<div class="line_center" style="justify-content: space-between;">' +
                    '       <div class="shield">' +
                    '          <span tapmode onclick=\'jubao(' + listData.id + ',event,3)\'>举报</span>' +
                    '          <span tapmode onclick=\'shield(' + listData.id + ',event,2,this)\'>屏蔽</span>' +
                    '       </div>' +
                    '       <div class="bottom-hot">' + listData.hot_number + '</div>' +
                    '     </div>';

            } else {
                shield = '<div class="bottom-hot">' + listData.hot_number + '</div>';
            }

            var　circle_title = '';
            if(isDefine(listData.circle_title)){
                circle_title = '<span class="bt-pd tips" tapmode onclick=\'commonUrl("../circle/circle_index",' + jsonChange(circleP) + ')\'>#' + listData.circle_title + '#</span></div>'
            }
            hotHtml = '<div class="detail-bottom">' +
                '              <div class="bottom-tips">' + toUp + circle_title + shield +
                '              </div>'+
                '       </div>';

        }


        if (isDefine(userData.badge_path)) {
            for (var k = 0; k < userData.badge_path.length; k++) {
                if (k <= 5) {
                    badgeList += '<dd class="icon"><img src="' + ajaxUrl + userData.badge_path[k] + '" alt=""></dd>'
                }
            }
        }
        var userVip = '';
        if(isDefine(userData.attestation_status)){
            if(userData.attestation_status == 2){
                userVip = '<span class="vip"></span>';
            }
        }

        if (isDefine(listData.self_status)) {

            if (listData.self_status == 2) {
                var className = 'class' + userData.id;

                if (listData.member_follow == '0') {
                    follow = '<div class="follow ' + className + '">' +
                        '         <span class="no-follow"  tapmode onclick="followAction(1,' + userData.id + ',this)">关注</span>' +
                        '         <span class="followed"  tapmode onclick="followAction(2,' + userData.id + ',this)">已关注</span>' +
                        '     </div>'
                } else {
                    /*follow = '<div class="follow ' + className + ' on">' +
                        '         <span class="no-follow"  tapmode onclick="followAction(1,' + userData.id + ',this)">关注</span>' +
                        '         <span class="followed"  tapmode onclick="followAction(2,' + userData.id + ',this)">已关注</span>' +
                        '     </div>'*/
                }

                var user = {'member_id': userData.id};
                var report = {type: 5, pid: userData.id}
                var jubao = '<div class="jubao" onclick=\'jubao('+userData.id+',event,5)\'>举报</div>'
                userInfo = '<div class="common-user-detail">' +
                    '           <div class="user-info" tapmode onclick=\'commonUrl("../activity/person_index",' + jsonChange(user) + ')\'>' +
                    '               <div class="userRelative"><div class="user-icon bg-cover" style="background-image: url(' + ajaxUrl + userData.icon_path + ');"></div>'+userVip+'</div>' +
                    '               <div class="info">' +
                    '                    <div class="name">' +
                    '                        <h6>' + userData.name + '</h6>' +
                    '                        <dl class="badge-list" tapmode onclick="toBadgePage(event)">' + badgeList + '</dl>' +
                    '                    </div>' +
                    '                    <span class="time">' + listData.date + '</span>' +
                    '                </div>' +
                    '            </div><div class="user-action">' + jubao + follow + '</div></div>';
            } else {

                userInfo = '<div class="common-user-detail">' +
                    '           <div class="user-info" tapmode onclick=\'\'>' +
                    '               <div class="userRelative"><div class="user-icon bg-cover" style="background-image: url(' + ajaxUrl + userData.icon_path + ');"></div>'+userVip+'</div>' +
                    '               <div class="info">' +
                    '                    <div class="name">' +
                    '                        <h6>' + userData.name + '</h6>' +
                    '                        <dl class="badge-list" tapmode onclick="toBadgePage(event)">' + badgeList + '</dl>' +
                    '                    </div>' +
                    '                    <span class="time">' + listData.date + '</span>' +
                    '                </div>' +
                    '            </div><div class="user-action">' + follow + '</div></div>';

            }

        }


        var actHtml = '';//活动内容
        var actStatus = '';//活动状态

        if (listData.status == 1) {
            actStatus = '<p class="status status1">报名中</p>'
        } else if (listData.status == 2) {
            actStatus = '<p class="status status3">进行中</p>'
        } else if (listData.status == 3) {
            actStatus = '<p class="status status2">已结束</p>'
        } else if (listData.status == 4) {
            actStatus = '<p class="status status3">报名截止</p>'
        } else {
            actStatus = '<p class="status status2">已取消</p>'
        }
        var icon_img = ''
        if (isDefine(listData.icons_path)) {
            icon_img = listData.icons_path[0]
        } else {
            icon_img = listData.background_path;
        }
        var activity = {'activity_id': listData.id};
        actHtml = '<div class="flex-div" tapmode onclick=\'commonUrl("../activity/activity_index",' + jsonChange(activity) + ')\'>' +
            '                    <div class="act-img bg-cover"  imgurl="'+ajaxUrl+icon_img+'" style="background: url('+ajaxUrl+icon_img+')"></div>' +
            '                    <div class="act-info">' +
            '                        <h6 class="single-ellipsis">' + listData.title + '</h6>' +
            '                        <div class="act-time">' +
            '                            <p class="time">' + listData.week + ' ' + listData.start_date + '</p>' + actStatus + '</div>' +
            '                        <div class="act-place">' +
            '                            <p class="place">' + listData.address + '</p>' +
            '                            <p class="num">' + listData.sum_number + '/' + listData.number + '</p>' +
            '                        </div>' +
            '                    </div>' +
            '                </div>';


        if(isDefine(type)){
            if(type == 1){
                listHtml += '<li style="border-bottom: 1px #f0f0f0 solid;" class="list-li">' + userInfo + actHtml + hotHtml + '</li>';
            }
        }else {
            listHtml += '<div class="activity-list"><ul>' +
                '<li style="border-bottom: 1px #f0f0f0 solid;" class="list-li">' + userInfo + actHtml + hotHtml + '</li>' +
                '</ul></div>'
        }

    }

    return listHtml;

}

//投票数据
function getVoteText(data,type){

    var listHtml = '';

    $.each(data,function (i, item) {
        var listData = item;
        var titleHtml = '';
        var userData = listData.member;

        var userInfo = '';
        var follow = '';//是否关注
        var badgeList = '';//徽章列表
        var toUp = '';//顶置
        var hotHtml = '';//标签，热度

        //顶置，标签，热度
        if (listData.recommend == 1) {
            toUp = '<span class="bt-pd toUp">置顶</span>';
        }
        var circleP = {"circle_id": listData.circle_id}

        if(listData.self_status == 2){
            if(isDefine(listData.circle_title)){
                var circle_title = '';
                if(type != 1){
                    circle_title = '<span class="bt-pd tips" tapmode onclick=\'commonUrl("../circle/circle_index",' + jsonChange(circleP) + ')\'>#' + listData.circle_title + '#</span>';
                }
                hotHtml = '<div class="detail-bottom">' +
                    '              <div class="bottom-tips">' + toUp + circle_title + '</div>' +
                    '               <div class="line_center" style="justify-content: space-between;">' +
                    '                                <div class="shield">' +
                    '                                    <span tapmode onclick=\'jubao('+listData.id+',event,3)\'>举报</span>' +
                    '                                    <span tapmode onclick=\'shield('+listData.id+',event,2,this)\'>屏蔽</span>' +
                    '                                </div>' +
                    '                                <div class="bottom-hot">' + listData.hot_number + '</div>' +
                    '                            </div>'+
                    '          </div>';
            }else {
                hotHtml = '<div class="detail-bottom">' +
                    '              <div class="bottom-tips">' + toUp +
                    '                   <span class="bt-pd"></span>' +
                    '               </div>' +
                    '               <div class="line_center" style="justify-content: space-between;">' +
                    '                                <div class="shield">' +
                    '                                    <span tapmode onclick=\'jubao('+listData.id+',event,3)\'>举报</span>' +
                    '                                    <span tapmode onclick=\'shield('+listData.id+',event,2,this)\'>屏蔽</span>' +
                    '                                </div>' +
                    '                                <div class="bottom-hot">' + listData.hot_number + '</div>' +
                    '                            </div>'+
                    '          </div>';
            }

        }else {
            if(isDefine(listData.circle_title)){
                var circle_title = '';
                if(type != 1){
                    circle_title = '<span class="bt-pd tips" tapmode onclick=\'commonUrl("../circle/circle_index",' + jsonChange(circleP) + ')\'>#' + listData.circle_title + '#</span>';
                }
                hotHtml = '<div class="detail-bottom">' +
                    '              <div class="bottom-tips">' + toUp + circle_title + '</div>' +
                    '               <div class="bottom-hot">' + listData.hot_number + '</div>'+
                    '          </div>';
            }else {
                hotHtml = '<div class="detail-bottom">' +
                    '              <div class="bottom-tips">' + toUp +
                    '              </div>'+
                    '               <div class="bottom-hot">' + listData.hot_number + '</div>'+
                    '          </div>';
            }

        }


        if (isDefine(userData.badge_path)) {
            for (var k = 0; k < userData.badge_path.length; k++) {
                if (k <= 5) {
                    badgeList += '<dd class="icon"><img src="' + ajaxUrl + userData.badge_path[k] + '" alt=""></dd>'
                }
            }
        }
        var userVip = '';
        if(isDefine(userData.attestation_status)){
            if(userData.attestation_status == 2){
                userVip = '<span class="vip"></span>';
            }
        }

        if(isDefine(listData.self_status)){

            if(listData.self_status == 2){
                var className = 'class'+userData.id;
                if (listData.member_follow == 0) {
                    follow = '<div class="follow '+className+'">' +
                        '         <span class="no-follow"  tapmode onclick="followAction(1,' + userData.id + ',this)">关注</span>' +
                        '         <span class="followed"  tapmode onclick="followAction(2,' + userData.id + ',this)">已关注</span>' +
                        '     </div>'
                } else {
                    /*follow = '<div class="follow '+className+' on">' +
                        '         <span class="no-follow"  tapmode onclick="followAction(1,' + userData.id + ',this)">关注</span>' +
                        '         <span class="followed"  tapmode onclick="followAction(2,' + userData.id + ',this)">已关注</span>' +
                        '     </div>'*/
                }

                var user = {'member_id': userData.id};
                var report = {type: 5,pid:userData.id}
                var jubao = '<div class="jubao" onclick=\'jubao('+userData.id+',event,5)\'>举报</div>'
                userInfo = '<div class="common-user-detail">' +
                    '           <div class="user-info" tapmode onclick=\'commonUrl("../activity/person_index",' + jsonChange(user) + ')\'>' +
                    '               <div class="userRelative"><div class="user-icon bg-cover" style="background-image: url(' + ajaxUrl + userData.icon_path + ');"></div>'+userVip+'</div>' +
                    '               <div class="info">' +
                    '                    <div class="name">' +
                    '                        <h6>' + userData.name + '</h6>' +
                    '                        <dl class="badge-list" tapmode onclick="toBadgePage(event)">' + badgeList + '</dl>' +
                    '                    </div>' +
                    '                    <span class="time">' + listData.date + '</span>' +
                    '                </div>' +
                    '            </div><div class="user-action">' + jubao + follow + '</div></div>';
            }else {

                userInfo = '<div class="common-user-detail">' +
                    '           <div class="user-info" tapmode onclick=\'commonUrl("../member/member")\'>' +
                    '               <div class="userRelative"><div class="user-icon bg-cover" style="background-image: url(' + ajaxUrl + userData.icon_path + ');"></div>'+userVip+'</div>' +
                    '               <div class="info">' +
                    '                    <div class="name">' +
                    '                        <h6>' + userData.name + '</h6>' +
                    '                        <dl class="badge-list" tapmode onclick="toBadgePage(event)">' + badgeList + '</dl>' +
                    '                    </div>' +
                    '                    <span class="time">' + listData.date + '</span>' +
                    '                </div>' +
                    '            </div><div class="user-action">' + follow + '</div></div>';
            }
        }

        var stype = '';//判断单选或者多选，其次 选项是否带图
        var result = '';//投票结果
        var stypeNote = '';//选择说明
        if(listData.status == 1){

            if(listData.member_status == 2){
                var entrylist = '';//条目数
                $.each(listData.entry,function(k,ktem){
                    var icon_path = '';
                    if(isDefine(ktem.icon_path)){
                        icon_path = '<div class="radio-img bg-cover" style="background: url(' + ajaxUrl + ktem.icon_path + ');"></div>'
                    }
                    entrylist += '<li data-id="'+ktem.id+'">' + icon_path + '<p class="multiline-ellipsis_3">'+ktem.content+'</p></li>';
                })

                if(listData.stype == 1){
                    if(listData.icon_status == 2){
                        stype = '<ul class="choose radioChoose" data-max="'+listData.many_number+'" data-min="'+listData.less_number+'">'+entrylist+'</ul><ul class="voteResult dn"></ul>';
                    }else {
                        stype = '<ul class="choose radioChoose imgChoose" data-max="'+listData.many_number+'" data-min="'+listData.less_number+'">'+entrylist+'</ul><ul class="voteResult dn"></ul>';
                    }
                    stypeNote = '<p>单选</p><p>'+listData.over_time_date+'截止</p>';
                } else {
                    if(listData.icon_status == 2){
                        stype = '<ul class="choose checkChoose" data-max="'+listData.many_number+'" data-min="'+listData.less_number+'">'+entrylist+'</ul><ul class="voteResult dn"></ul>';
                    }else {
                        stype = '<ul class="choose checkChoose imgChoose" data-max="'+listData.many_number+'" data-min="'+listData.less_number+'">'+entrylist+'</ul><ul class="voteResult dn"></ul>';
                    }
                    stypeNote = '<p>多选；最多可选'+listData.many_number+'项，最少'+listData.less_number+'项</p><p>'+listData.over_time_date+'截止</p>';
                }
            }else {
                var voteResult = '';//投票结果li
                $.each(listData.entry,function(k,ktem){

                    var on = '';
                    if(ktem.member_status == 1){
                        on = 'on';
                    }
                    voteResult += '<li class="'+on+'">'+
                        '    <p class="multiline-ellipsis_3">'+ktem.content+'</p>'+
                        '    <div class="result">'+ktem.number+'票（'+(parseFloat(ktem.entry_rate)*100).toFixed(2)+'%）</div>'+
                        '    <div class="percentage" style="width: '+(parseFloat(ktem.entry_rate)*100).toFixed(2)+'%;"></div>'+
                        '</li>';
                })
                if(listData.stype == 1){
                    stypeNote = '<p>单选</p><p>'+listData.over_time_date+'截止</p>';
                } else {
                    stypeNote = '<p>多选；最多可选'+listData.many_number+'项，最少'+listData.less_number+'项</p><p>'+listData.over_time_date+'截止</p>';
                }
                result = '<ul class="voteResult">'+voteResult+'</ul>';
            }
        }else {

            var voteResult = '';//投票结果li
            $.each(listData.entry,function(k,ktem){

                var on = '';
                if(ktem.member_status == 1){
                    on = 'on';
                }
                voteResult += '<li class="'+on+'">'+
                    '    <p class="multiline-ellipsis_3">'+ktem.content+'</p>'+
                    '    <div class="result">'+ktem.number+'票（'+(parseFloat(ktem.entry_rate)*100).toFixed(2)+'%）</div>'+
                    '    <div class="percentage" style="width: '+(parseFloat(ktem.entry_rate)*100).toFixed(2)+'%;"></div>'+
                    '</li>';
            })
            if(listData.stype == 1){
                stypeNote = '<p>单选</p><p>'+listData.over_time_date+'截止</p>';
            } else {
                stypeNote = '<p>多选；最多可选'+listData.many_number+'项，最少'+listData.less_number+'项</p><p>'+listData.over_time_date+'截止</p>';
            }
            result = '<ul class="voteResult">'+voteResult+'</ul>';
        }


        var voteBtn = '';//是否为本人，是否已投票，本人为1；
        var vote_id = {'vote_id': listData.id,"type": 2};

        if(listData.self_status == 1){
            if(listData.member_status == 2){
                if(listData.status == 1){
                    voteBtn = '<div tapmode onclick=\'commonUrl("../circle/vote_result",' + jsonChange(vote_id) + ')\' class="look-btn btn">查看结果</div>' +
                        '<div class="vote-btn btn" tapmode onclick="actionVote(2,'+listData.id+',this)">投票</div>';
                }else {
                    voteBtn = '<div tapmode onclick=\'commonUrl("../circle/vote_result",' + jsonChange(vote_id) + ')\' class="look-btn btn">查看结果</div>' +
                        '<div class="voted-btn btn">已结束</div>';
                }

            }else {
                voteBtn = '<div tapmode onclick=\'commonUrl("../circle/vote_result",' + jsonChange(vote_id) + ')\' class="look-btn btn">查看结果</div>' +
                    '<div class="voted-btn btn">已投票</div>';
            }
        }else {
            if(listData.member_status == 2){
                if(listData.status == 1){
                    voteBtn = '<div class="vote-btn btn" tapmode onclick="actionVote(2,'+listData.id+',this)">投票</div>';
                }else {
                    voteBtn = '<div class="voted-btn btn">已结束</div>';
                }

            }else {
                voteBtn = '<div class="voted-btn btn">已投票</div>';
            }
        }

        var voteStatus = '';//投票是否截止
        if(listData.status == 1){
            voteStatus = '<span class="status being">进行中</span>';
        }else {
            voteStatus = '<span class="status end">已结束</span>';
        }

        var votePic = '';//投票图
        if(isDefine(listData.icon_path)){
            votePic = '<div class="votePic bg-cover" style="width: 100%;height: 3.5rem; border-radius: 0.1rem; background: url('+ajaxUrl + listData.icon_path+')" tapmode onclick=\'commonUrl("../circle/vote_detail",' + jsonChange(vote_id) + ')\'>' +
                // '              <img src="'+ajaxUrl + listData.icon_path+'" alt="">' +
                '          </div>';
        }

        titleHtml = '<div class="video-detail">' +
            '            <h6 tapmode onclick=\'commonUrl("../circle/vote_detail",' + jsonChange(vote_id) + ')\' class="news-title multiline-ellipsis_3">' + voteStatus + listData.title +
            '</h6>' + votePic + '<div class="voteView">' + stype + result + '<div class="vote-note">' + stypeNote + '</div>' +
            '              <div class="vote-action">' + voteBtn + '</div>' +
            '           </div>' + hotHtml +
            '         </div>';

        listHtml += '<li>' + userInfo + titleHtml + '</li>';

    })


    return listHtml;



}


//关闭认证弹窗
function closeRzModel() {
    $(".rzModel").hide();
}
//前往认证
function toSchoolRz() {
    commonUrl('../member/schoolRz');
    setTimeout(function () {
        $(".rzModel").hide();
    },1000)
}

var rzHtml = '<div class="rzModel">' +
    '    <div class="rzSection">' +
    '        <div class="rzInfo">' +
    '            Uni发现你还没有认证呦<br>认证之后可解锁学校板块更多内容~' +
    '        </div>' +
    '        <div class="rzBtn">' +
    '            <a href="javascript:void(0);" class="confirm" tapmode onclick="toSchoolRz()">前往认证</a>' +
    '            <a href="javascript:void(0);" class="cancel" tapmode onclick="closeRzModel()">暂不认证</a>' +
    '        </div>' +
    '    </div>' +
    '</div>';


//跳转到所有评论列表
function getAllList(type,key_id) {
    var param = {
        type: type,
        key_id: key_id
    }
    commonUrl('../activity/comment_all',param)
}

//获取所有评论
function getAllPl(type,key_id,page,fun) {
    var param = {
        token: $api.getStorage('token'),
        type: type,//type: 1新闻，2帖子，3活动贴，4赛事，5战况，6投票，7广场评星
        key_id: key_id,
        page: page,
    }
    console.log(jsonChange(param))
    pop.loading();
    getAjax(Interface.getAllList,param,function (res) {
        fun(res);
        pop.close();
    },function (error) {
        pop.close();
        pop.notice(error.msg);
    })

}


$("#doubleClick").dblclick(function () {

    $('#mescroll').animate({scrollTop:0},500);//回到顶端

});


function getEvaluteList(data,key_id) {
    var commentHtml = '';
    var comment = data;
    for (var i = 0; i < comment.length; i++) {
        //楼主的徽章列表
        var badgeHtml = '';
        if (isDefine(comment[i].member_badge_path)) {
            for (var y = 0; y < comment[i].member_badge_path.length; y++) {
                badgeHtml += '<dd class="icon"><img src="' + ajaxUrl + comment[i].member_badge_path[y] + '" alt=""></dd>';
            }
        }
        //楼主的回复总条数
        var count = '';
        if(isDefine(key_id)){
            if (comment[i].count > 2) {
                var c_id = {"id": comment[i].id, 'detail_id': key_id};
                count = '<a href="javascript:void(0);" style="margin: 0.05rem 0; display: inline-block;" class="reply-count" tapmode onclick=\'commonUrl("../activity/comment_detail",' + jsonChange(c_id) + ')\'>共' + comment[i].count + '条回复 ></a>'
            }
        }


        //二级回复列表
        var replyHtml = '';
        var reply_ul = comment[i].details;
        if (isDefine(reply_ul)) {
            for (var aa = 0; aa < reply_ul.length; aa++) {
                if(isDefine(key_id)){
                    if (aa < 2) {
                        var reply_li = '';//回复列
                        var replyUser = '';//回复列的用户名称
                        var reply_badge = '';//回复列的用户徽章
                        if (isDefine(reply_ul[aa].member_badge_path)) {
                            for (var bb = 0; bb < reply_ul[aa].member_badge_path.length; bb++) {
                                reply_badge += '<dd class="icon"><img src="' + ajaxUrl + reply_ul[aa].member_badge_path[bb] + '" alt=""></dd>';
                            }
                        }
                        replyUser = '<div class="list-user-info"  tapmode onclick=\'reply(' + reply_ul[aa].id + ',"' + reply_ul[aa].member_name + '")\'>' +
                            '     <p class="user-name" >' + reply_ul[aa].member_name + '</p>' +
                            '     <dl class="badge-list ml5">' + reply_badge + '</dl><span class="ml15 f20 c-999">' + reply_ul[aa].date + '</span>' +
                            '</div>'

                        var Rimg = '';
                        if(reply_ul[aa].icon != 0){
                            Rimg = '<div class="imglist"><div class="photoSwiper"><div class="img-dv"><a href="javascript:void(0);" style="display: block; width: 100%"><img style="width: 100%" src="'+ajaxUrl+reply_ul[aa].icon_path+'" alt=""></a></div></div></div>'
                        }
                        var Rtxt = '';
                        if(isDefine(reply_ul[aa].content)){
                            Rtxt = '<div style="display: block; word-break: break-all;" tapmode onclick=\'reply(' + reply_ul[aa].id + ',"' + reply_ul[aa].member_name + '")\'>'+reply_ul[aa].content+'</div>';
                        }
                        var Rvideo = '';
                        if(isDefine(reply_ul[aa].void_id) && reply_ul[aa].void_id != 0){
                            Rvideo = '<p style="text-decoration: underline; color: #ff7777;" tapmode onclick=\'play("'+ajaxUrl+reply_ul[aa].void_path+'")\'>点击播放视频</p>';
                        }

                        //是否为一级回复 1为一级回复
                        if (reply_ul[aa].level == 1) {
                            reply_li = ' <div class="list-reply-li">' + replyUser + '<div class="list-reply-detail">' + Rtxt + Rimg + Rvideo + '</div></div>';
                        } else {
                            reply_li = ' <div class="list-reply-li">' + replyUser + '<div class="list-reply-detail"><span>回复 <em class="c-primary">' + reply_ul[aa].p_name + '</em>：</span>' + Rtxt + Rimg + Rvideo + '</div></div>'
                        }
                        replyHtml += '<div class="list-reply-ul">' + reply_li + '</div>';
                    }
                }else {
                    var reply_li = '';//回复列
                    var replyUser = '';//回复列的用户名称
                    var reply_badge = '';//回复列的用户徽章
                    if (isDefine(reply_ul[aa].member_badge_path)) {
                        for (var bb = 0; bb < reply_ul[aa].member_badge_path.length; bb++) {
                            reply_badge += '<dd class="icon"><img src="' + ajaxUrl + reply_ul[aa].member_badge_path[bb] + '" alt=""></dd>';
                        }
                    }
                    replyUser = '<div class="list-user-info"  tapmode onclick=\'reply(' + reply_ul[aa].id + ',"' + reply_ul[aa].member_name + '")\'>' +
                        '     <p class="user-name" >' + reply_ul[aa].member_name + '</p>' +
                        '     <dl class="badge-list ml5">' + reply_badge + '</dl><span class="ml15 f20 c-999">' + reply_ul[aa].date + '</span>' +
                        '</div>'

                    var Rimg = '';
                    if(reply_ul[aa].icon != 0){
                        Rimg = '<div class="imglist"><div class="photoSwiper"><div class="img-dv"><a href="javascript:void(0);" style="display: block; width: 100%"><img style="width: 100%" src="'+ajaxUrl+reply_ul[aa].icon_path+'" alt=""></a></div></div></div>'
                    }
                    var Rtxt = '';
                    if(isDefine(reply_ul[aa].content)){
                        Rtxt = '<div style="display: block;word-break: break-all;"  tapmode onclick=\'reply(' + reply_ul[aa].id + ',"' + reply_ul[aa].member_name + '")\'>'+reply_ul[aa].content+'</div>';
                    }
                    var Rvideo = '';
                    if(isDefine(reply_ul[aa].void_id) && reply_ul[aa].void_id != 0){
                        Rvideo = '<p style="text-decoration: underline; color: #ff7777;" tapmode onclick=\'play("'+ajaxUrl+reply_ul[aa].void_path+'")\'>点击播放视频</p>';
                    }

                    //是否为一级回复 1为一级回复
                    if (reply_ul[aa].level == 1) {
                        reply_li = ' <div class="list-reply-li">' + replyUser + '<div class="list-reply-detail">' + Rtxt + Rimg + Rvideo + '</div></div>';
                    } else {
                        reply_li = ' <div class="list-reply-li">' + replyUser + '<div class="list-reply-detail"><span>回复 <em class="c-primary">' + reply_ul[aa].p_name + '</em>：</span>' + Rtxt + Rimg + Rvideo + '</div></div>'
                    }
                    replyHtml += '<div class="list-reply-ul">' + reply_li + '</div>';
                }

            }
        }

        //是否点赞
        var fabulous = '';
        if (comment[i].fabulous == 2) {
            fabulous = '<div class="fabulous " tapmode onclick=\'clickFabulous(1,4,"' + comment[i].id + '",event)\'>' + comment[i].fabulous_number + '</div>'
        } else {
            fabulous = '<div class="fabulous on" tapmode onclick=\'clickFabulous(2,4,"' + comment[i].id + '",event)\'>' + comment[i].fabulous_number + '</div>'
        }

        var m_id = '', mUrl = '';
        var user_id = $api.getStorage('userInfo').id;
        if(comment[i].member_id == user_id){
            // mUrl = '../member/member';
        }else {
            mUrl = '../activity/person_index';
            m_id = {member_id:comment[i].member_id}
        }

        var report = {type: 5,pid:comment[i].id}
        var commentImg = '';
        console.log(comment[i].icon)
        if(comment[i].icon != 0){
            commentImg = '<div class="imglist"><div class="photoSwiper"><div class="img-dv"><a href="javascript:void(0);" style="display: block; width: 100%"><img style="width: 100%" src="'+ajaxUrl+comment[i].icon_path+'" alt=""></a></div></div></div>'
        }
        var commentTxt = '';
        if(isDefine(comment[i].content)){
            commentTxt = '<p>'+comment[i].content+'</p>';
        }
        var commentVideo = '';
        if(isDefine(comment[i].void_id) && comment[i].void_id != 0){
            commentVideo = '<p style="text-decoration: underline; color: #ff7777;" tapmode onclick=\'play("'+ajaxUrl+comment[i].void_path+'")\'>点击播放视频</p>';
        }

        commentHtml += '<li>' +
            '                    <div class="list-user-info">' +
            '                        <div class="userRelative" tapmode onclick=\'commonUrl("'+mUrl+'",'+jsonChange(m_id)+')\' style="width: 0.6rem; height: 0.6rem;"><div class="user-img bg-cover" style="background-image: url(' + ajaxUrl + comment[i].member_icon + ');"></div><span class="vip"></span></div>' +
            '                        <p class="user-name" tapmode onclick=\'commonUrl("'+mUrl+'",'+jsonChange(m_id)+')\'>' + comment[i].member_name + '</p>' +
            '                        <dl class="badge-list ml5" tapmode onclick="toBadgePage(event)">' + badgeHtml + '</dl>' + fabulous +
            '                    </div>' +
            '                    <div class="list-detail">' +
            '                        <div class="detail">' + commentTxt + commentImg + commentVideo +'</div>' +
            '                        <div class="list-reply">' + replyHtml + count + '</div>' +
            '                        <div class="list-flex">' +
            '                            <div class="list-time">' +
            '                                <span>' + comment[i].date + '</span>' +
            '                                <a href="javascript:void(0);" tapmode onclick=\'reply("' + comment[i].id + '","' + comment[i].member_name + '")\' class="c-primary">回复</a>' +
            '                            </div>' +
            '                            <a href="javascript:void(0);" tapmode onclick=\'commonUrl("../member/jubao",'+jsonChange(report)+')\' class="list-action"></a>' +
            '                        </div>' +
            '                    </div>' +
            '                </li>';

    }

    return commentHtml;

}


function getEvaluteList_gc(data,key_id) {
    var commentHtml = '';
    var comment = data;
    for (var i = 0; i < comment.length; i++) {
        var list = comment[i];
        var member = comment[i].member;
        //楼主的徽章列表
        var badgeHtml = '';
        if (isDefine(member.member_badge_path)) {
            for (var y = 0; y < member.member_badge_path.length; y++) {
                badgeHtml += '<dd class="icon"><img src="' + ajaxUrl + member.member_badge_path[y] + '" alt=""></dd>';
            }
        }
        //楼主的回复总条数
        var count = '';
        if (comment[i].comment_count > 2) {
            var c_id = {"id": comment[i].id, 'detail_id': key_id};
            // count = '<a href="javascript:void(0);" style="display: block;" class="reply-count pt10 pb10" tapmode onclick=\'commonUrl("../activity/comment_detail",' + jsonChange(c_id) + ')\'>共' + comment[i].comment_count + '条回复 ></a>'
        }

        //二级回复列表
        var replyHtml = '';
        var reply_ul = comment[i].details;
        if (isDefine(reply_ul)) {
            for (var aa = 0; aa < reply_ul.length; aa++) {
                    var reply_li = '';//回复列
                    var replyUser = '';//回复列的用户名称
                    var reply_badge = '';//回复列的用户徽章
                    if (isDefine(reply_ul[aa].member_badge_path)) {
                        for (var bb = 0; bb < reply_ul[aa].member_badge_path.length; bb++) {
                            reply_badge += '<dd class="icon"><img src="' + ajaxUrl + reply_ul[aa].member_badge_path[bb] + '" alt=""></dd>';
                        }
                    }
                    replyUser = '<div class="list-user-info"  tapmode onclick=\'replySecond('+comment[i].id+',' + reply_ul[aa].id + ',"' + reply_ul[aa].member_name + '")\'>' +
                        '     <p class="user-name">' + reply_ul[aa].member_name + '</p>' +
                        '     <dl class="badge-list ml5">' + reply_badge + '</dl><span class="ml15 f20 c-999">' + reply_ul[aa].date + '</span>' +
                        '</div>'

                    var Rimg = '';
                    if(reply_ul[aa].icon != 0){
                        Rimg = '<div class="imglist"><div class="photoSwiper"><div class="img-dv"><a href="'+ajaxUrl+reply_ul[aa].icon_path +'" style="display: block; width: 100%"><img style="width: 100%" src="'+ajaxUrl+reply_ul[aa].icon_path+'" alt=""></a></div></div></div>'
                    }
                    var Rtxt = '';
                    if(isDefine(reply_ul[aa].content)){
                        Rtxt = '<p style="word-break: break-all;" class="pt10">'+reply_ul[aa].content+'</p>';
                    }
                    var Rvideo = '';
                    if(isDefine(reply_ul[aa].void_id) && reply_ul[aa].void_id != 0){
                        Rvideo = '<p style="text-decoration: underline; color: #ff7777;" tapmode onclick=\'play("'+ajaxUrl+reply_ul[aa].void_path+'")\'>点击播放视频</p>';
                    }

                    reply_li += ' <div class="list-reply-li">' + replyUser + '<div class="list-reply-detail">' + Rtxt + Rimg + Rvideo + '</div></div>';


                    if(isDefine(reply_ul[aa].details)){

                        $.each(reply_ul[aa].details,function(i,item){

                            var reply_badge2 = '', replyUser2='';

                            var itemimg = '';
                            if(item.icon != 0){
                                itemimg = '<div class="imglist"><div class="photoSwiper"><div class="img-dv"><a href="'+ajaxUrl+item.icon_path +'" style="display: block; width: 100%"><img style="width: 100%" src="'+ajaxUrl+item.icon_path+'" alt=""></a></div></div></div>'
                            }
                            var itemtxt = '';
                            if(isDefine(item.content)){
                                itemtxt = '<p style="word-break: break-all;" class="pt10">'+item.content+'</p>';
                            }
                            var itemvideo = '';
                            if(isDefine(item.void_id) && item.void_id != 0){
                                itemvideo = '<p style="text-decoration: underline; color: #ff7777;" tapmode onclick=\'play("'+ajaxUrl+item.void_path+'")\'>点击播放视频</p>';
                            }

                            if (isDefine(item.member_badge_path)) {
                                for (var bb = 0; bb < item.member_badge_path.length; bb++) {
                                    reply_badge2 += '<dd class="icon"><img src="' + ajaxUrl + item.member_badge_path[bb] + '" alt=""></dd>';
                                }
                            }

                            replyUser2 += '<div class="list-user-info"  tapmode onclick=\'replySecond(' + item.id + ',"' + item.member_name + '")\'>' +
                                '     <p class="user-name" >' + item.member_name + '</p>' +
                                '     <dl class="badge-list ml5">' + reply_badge2 + '</dl><span class="ml15 f20 c-999">' + item.date + '</span>' +
                                '</div>'


                            reply_li += ' <div class="list-reply-li">' + replyUser2 + '<div class="list-reply-detail"><span>回复 <em class="c-primary">' + item.p_name + '</em>：</span>' + itemtxt + itemimg + itemvideo + '</div></div>'
                        })
                    }


                    replyHtml += '<div class="list-reply-ul">' + reply_li + '</div>';
            }
        }

        //是否点赞
        var fabulous = '';
        if (comment[i].fabulous_status == 2) {
            fabulous = '<div class="fabulous " tapmode onclick=\'clickFabulous(1,8,"' + comment[i].id + '",event)\'>' + comment[i].fabulous_number + '</div>'
        } else {
            fabulous = '<div class="fabulous on" tapmode onclick=\'clickFabulous(2,8,"' + comment[i].id + '",event)\'>' + comment[i].fabulous_number + '</div>'
        }

        var m_id = '', mUrl = '';
        var user_id = $api.getStorage('userInfo').id;
        if(member.id == user_id){
            // mUrl = '../member/member';
        }else {
            mUrl = '../activity/person_index';
            m_id = {member_id: member.id}
        }

        var report = {type: 5,pid: member.id}
        var commentTxt = '';
        if(isDefine(list.content)){
            commentTxt = '<p class="pt15 pb10">'+list.content+'</p>';
        }else {
            commentTxt = '<p class="pt15 pb10">该用户暂未评论</p>'
        }

        var anon = ''
        if(list.anonymous == 1){
            anon = '<div class="list-flex-space">'
        }else {
            anon = '<div class="list-flex-space" tapmode onclick=\'commonUrl("' + mUrl + '",' + jsonChange(m_id) + ')\'>'
        }


        commentHtml += '<li>' +
            '                    <div class="list-user-info" >' + anon +
            '                            <div class="user-img bg-cover" style="background-image: url(' + ajaxUrl + member.icon_path + ');"></div>' +
            '                            <div class="star-flex">'+
            '                                <div class="user-name">' + member.name + '<dl class="badge-list ml5" tapmode onclick="toBadgePage(event)">' + badgeHtml + '</dl></div>'+
            '                            <div style="display:flex; align-items: center;">'+
            '                                <div class="eStar mr10" data-num="'+list.aver_socre+'"></div>'+
            '                                <span class="f24">'+list.aver_socre+'分</span>'+
            '                            </div>' +
            '                            </div>'+
            '                        </div>' + fabulous +
            '                    </div>' +
            '                    <div class="list-detail">' +
            '                        <div class="detail">' + commentTxt + '</div>' +
            '                        <div class="list-reply">' + replyHtml + count + '</div>' +
            '                        <div class="list-flex">' +
            '                            <div class="list-time">' +
            '                                <span>' + list.date + '</span>' +
            '                                <a href="javascript:void(0);" tapmode onclick=\'reply("' + list.id + '","' + member.name + '")\' class="c-primary">回复</a>' +
            '                            </div>' +
            '                            <a href="javascript:void(0);" tapmode onclick=\'commonUrl("../member/jubao",' + jsonChange(report) + ')\' class="list-action"></a>' +
            '                        </div>' +
            '                    </div>' +
            '                </li>';

    }

    return commentHtml;

}

//艾特跳转

function toAiteList() {
    commonUrl('../member/chooseMyLike');
}

//分享app成功回执
function shareSuccess() {
    var param = {
        token: $api.getStorage('token')
    }
    getAjax(Interface.new_share,param,function (res) {
        console.log(res.msg)
        get_integral();
    },function (error) {
        console.log(error.msg)
    })
}


function _insertimg(str) {

    $("#article").append(str);
    return;

    var selection = window.getSelection ? window.getSelection() : document.getSelection;

    var range = selection.createRange ? selection.createRange() : selection.getRangeAt(0);


    if (!window.getSelection) {

        document.getElementById('article').focus();

        range.pasteHTML(str);

        range.collapse(false);

        range.select();

    } else {

        document.getElementById('article').focus();

        range.collapse(false);

        var hasR = range.createContextualFragment(str);

        var hasR_lastChild = hasR.lastChild;

        while (hasR_lastChild && hasR_lastChild.nodeName.toLowerCase() == "br" && hasR_lastChild.previousSibling &&
        hasR_lastChild.previousSibling.nodeName.toLowerCase() == "br") {

            var e = hasR_lastChild;

            hasR_lastChild = hasR_lastChild.previousSibling;

            hasR.removeChild(e)

        }

        range.insertNode(hasR);

        if (hasR_lastChild) {

            range.setEndAfter(hasR_lastChild);

            range.setStartAfter(hasR_lastChild)

        }

        selection.removeAllRanges();

        selection.addRange(range)

    }

}


